Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • thanhtien501 28 posts 48 karma points
    Nov 18, 2010 @ 11:15

    Error when create a macro using .NET user control

    Dear All

    I have a problem

    I create a user control

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="TestUmbracoUserControll.ascx.cs" Inherits="TestUmbracoUserControll" %>
    <asp:Label ID="Label1" runat="server" Text="Chao ban"></asp:Label><br />
    <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />

    the code

    public partial class TestUmbracoUserControll : System.Web.UI.UserControl
    protected void Page_Load(object sender, EventArgs e)

    protected void Button1_Click(object sender, EventArgs e)
    Label1.Text = "chao gi a";

    After that i deploy and code *.dll into  bin folder and *.ascx to the usercontrol folder of installed umbraco

    +Put the *.dll in bin folder into the bin folder of the installed umbraco.

    +Put the .ascx file into the usercontrols folder of the isntalled umbraco

    Create a macro  and browser to the ascx file

    Use the macro in the master page

    <umbraco:Macro ID="Macro5" Alias="MyTestMacro"  runat="server"></umbraco:Macro>


    Server Error in '/' Application.
    Control 'ContentPlaceHolderDefault_BIDCContactForm_3_Button1' of type 'Button' must be placed inside a form tag with runat=server.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Web.HttpException: Control 'ContentPlaceHolderDefault_BIDCContactForm_3_Button1' of type 'Button' must be placed inside a form tag with runat=server.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [HttpException (0x80004005): Control 'ContentPlaceHolderDefault_BIDCContactForm_3_Button1' of type 'Button' must be placed inside a form tag with runat=server.]
    System.Web.UI.Page.VerifyRenderingInServerForm(Control control) +8910280
    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1


    please help me

    thank you for your patience

  • Rich Green 2246 posts 4008 karma points
    Nov 18, 2010 @ 11:17
    Rich Green


    You need to place the following code around where you macro is entered, however there can one be ONE of these special form tags on your site so you may want to put it on the master page.

    <form runat="server">
        <!--any .net macros must go here-->

    Hope that helps


  • Eduardo 106 posts 130 karma points
    Nov 18, 2010 @ 11:26


    Controls must be enclosed between form tags!!


    Sincere regards,

  • thanhtien501 28 posts 48 karma points
    Nov 18, 2010 @ 12:26

    Hi thanh you , rich green and Edurdo. the problem was solved

  • LUIZ JUNIOR 4 posts 24 karma points
    Jan 08, 2013 @ 15:57

    First, sorry for my english 'cos I'm Brazilian, well, my problem is...

    My template structure:


      |__ Quem somos (subpage with body text content)

      |__ Contatos (subpage with body text content)

      |__ Noticias (subpage with body text content)

    I have a form.ascx in the usercontrols folder and form.ascx.cs in the App_code, up to here ok.

    I load this macro without problem in my subpages template (quem somos | contatos | noticias | ...) but in the Home page the componets stop the read code when the code read some like asp:textbox then shows anything more about the form.ascx.

    Can somebody help me?

  • Grant Thomas 291 posts 324 karma points
    Jan 08, 2013 @ 16:05
    Grant Thomas

    Luiz, ideally you should create a new topic for your specific problem if there arn't enough details in this thread to solve it.

    Preferably provide as much information as possible, too, such as error messages and such, rather than 'it stops working', which doesn't really help anyone help you.

Please Sign in or register to post replies

Write your reply to: