Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > RadControls in ASP.NET MVC > 'Button' must be placed inside a form tag with runat=server

Not answered 'Button' must be placed inside a form tag with runat=server

Feed from this thread
  • Adam Miller avatar

    Posted on Jul 8, 2009 (permalink)

    Full Error: Control 'RadGrid1_ctl00_ctl02_ctl00_ctl04' of type 'Button' must be placed inside a form tag with runat=server

    Details:
    I'm placing a radgrid in a usercontrol, the usercontrol will be placed on an mvc page 6 times.  The radcontrol works if it is alone on a page (not int a user control) using the following code:
    <body>
        <form runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
        <telerik:RadGrid ID="RadGrid1" AutoGenerateColumns="false" runat="server">
            <MasterTableView>
                <Columns>
                    <telerik:GridBoundColumn DataField="region" DataType="System.String" HeaderText="regionheader" />
                    <telerik:GridBoundColumn DataField="playCount" DataType="System.Int32" HeaderText="playcountheader" />
                </Columns>
            </MasterTableView>
            <ClientSettings>
                <DataBinding Location="/ASP/GridWS.asmx" SelectMethod="GetData" SelectCountMethod="GetCount" />
            </ClientSettings>
        </telerik:RadGrid>
        </form>
    </body>

    However I get the error when I attempt to place the grid in the control on the page.  If I move the <form> tag from the page to the control it will render without the error, but I need to have the form on the page as there are other controls that need to post, and basically because it seems like bad practice.

    Reply

  • Dallas Sehlhorst avatar

    Posted on Jul 8, 2009 (permalink)

    Adam,

    Try adding this to your View page:

    <script runat="server"
     public override void VerifyRenderingInServerForm(Control control) 
     { 
     } 
    </script> 

    I had a similar problem, and this fixed it.  This should suppress the rendering in a form issue you are experiencing.

    Hope this helps,

    -Dallas

    Reply

  • Adam Miller avatar

    Posted on Jul 8, 2009 (permalink)

    overriding VerifyRenderingInServerForm allows me to remove the form tag from a simple page that does not use custom usercontrols that host the radgrid, but I still get the error on my page (which has a master page) when putting my user control on the page.

    Reply

  • Adam Miller avatar

    Posted on Jul 8, 2009 (permalink)

    I have confirmed that this issue is directly associated with loading the radgrid in a user control on the mvc page.
    <ContentTemplate> 
        <% Html.RenderPartial("Widget", Model[0]); %> 
    </ContentTemplate> 

    Reply

  • Sebastian Sebastian admin's avatar

    Posted on Jul 9, 2009 (permalink)

    Hello Adam,

    Can you please inspect the rendered html of the grid when it resides on the pag itself (using IE developer toolbar or Firebug) to see whether it contains input type=button inside its body? This can be the reason why you get the error that the button requires form with runat=server tag.

    To bypass it, disable the functionality which generates button(s) as part of the grid body.

    Kind regards,
    Sebastian
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.

    Reply

  • Francis Go avatar

    Posted on Sep 1, 2009 (permalink)

    Hello Adam,

    I'm not sure if this will help you. I was getting the same error when I was adding my user controls to the page by code.
    I fixed it by changing Page.Controls.Add() to Form.Controls.Add. After doing that, the page rendered perfectly and the errors were gone.
    It's a bit confusing because on some pages, Page.Controls.Add() to add custom controls works fine. On others, it crashes.

    Hope this helps.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > RadControls in ASP.NET MVC > 'Button' must be placed inside a form tag with runat=server