Web Forms for Marketers

Add an ASCX control to the page


After converting a form to an ascx file, you can add it to your page.

In the Web Forms for Marketers module, you can convert and export a form to an .ascx file and then add it to your website as an ASCX control. For developers, this can make it easier to develop their custom form control.

To add an ASCX control to the page:

  1. Using a text editor, in the \layouts folder of your Sitecore installation, create a new default.aspx page and insert the following code:

    <%@ Page Language="C#" AutoEventWireup="true" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
        <form id="form1" runat="server">
  2. In the Form Designer, in the Export group, click To ASCX and export the relevant form data to the \layouts folder. Use the forms.ascx format for the name of the file.

  3. In the default.aspx page that you created, add the following code after the first <%@ Page> tag:

     <%@ Register Src="form.ascx" TagName="SimpleForm" TagPrefix="uc1" %>
  4. Inside the <form> tag, insert the following code:

            <uc1:SimpleForm ID="WebUserControl1" runat="server" />        
  5. In your web browser, enter the following URL: http://localhost/layouts/default.aspx.


After you make changes to the .ascx file, the module does not verify that the form works correctly