Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom form in Umbraco limitations?

Tags:

umbraco

I am busy learning about Umbraco but I don't see anything on the internet that tells me if Umbraco will allow me to create a custom ASP.NET form using C# code connecting to a SQL Server Database.

Would I have any issues with Umbraco if I need to create such a custom form in ASP.NET and bring it into Umbraco?

like image 844
Etienne Avatar asked Dec 30 '25 11:12

Etienne


2 Answers

There are two ways (that I know of, at least) where you can implement custom .Net forms in Umbraco (Version 4.7.x and below).

Template-Based

You can build the form directly in the template markup using standard ASP.Net controls and using a <script runat="server" language="c#"> tag. This is standing inline page coding as you would in Visual Studio, so you give up the luxuries of pre-compilation etc.

<%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>
<asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
    <asp:Label ID="myLabel" runat="server" />
</asp:Content>
<script runat="server" language="c#">
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            this.myLabel.Text = "Hello World";
        }    
    }  
</script>

Macro-Based

  1. Build your forms in User Controls in Visual Studio and compile it.
  2. Copy the .ascx to the /usercontrols/ folder.
  3. Copy the .dll to the /bin/ folder.
  4. Navigate to Developer > Macros in Umbraco and create a new Macro
  5. Select your user control from the drop down next to .Net User Control on the Macro Properties tab.
  6. Import you macro into your template. Done!
  7. (Optional) If you user control requires properties to be set, don't forget to add them to properties tab in your macro and map them.

Your template code will look something like the following:

<%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>
<asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
    <umbraco:Macro Alias="MyForm" MyProperty="Hi!" runat="server" />
</asp:Content>
like image 65
Goran Mottram Avatar answered Dec 31 '25 23:12

Goran Mottram


Another fast and cheap option is using the Contour Forms package. It costs about 99 euros and provides a WYSIWYG interface to creating forms. It has workflow and the ability to store the values in custom tables.

We really like it and it works for probably 75% - 80% of cases where you need a form.

http://umbraco.com/products/more-add-ons/contour.aspx

like image 21
BeaverProj Avatar answered Dec 31 '25 23:12

BeaverProj



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!