This is a migrated thread and some comments may be shown as answers.

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

5 Answers 1409 Views
UI for ASP.NET AJAX in ASP.NET MVC
This is a migrated thread and some comments may be shown as answers.
Adam Miller
Top achievements
Rank 1
Adam Miller asked on 08 Jul 2009, 04:22 PM
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.

5 Answers, 1 is accepted

Sort by
0
Dallas Sehlhorst
Top achievements
Rank 1
answered on 08 Jul 2009, 05:20 PM
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
0
Adam Miller
Top achievements
Rank 1
answered on 08 Jul 2009, 07:00 PM
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.
0
Adam Miller
Top achievements
Rank 1
answered on 08 Jul 2009, 07:15 PM
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> 

0
Sebastian
Telerik team
answered on 09 Jul 2009, 08:41 AM
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.
0
JR Go
Top achievements
Rank 1
answered on 01 Sep 2009, 03:31 PM
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.
Tags
UI for ASP.NET AJAX in ASP.NET MVC
Asked by
Adam Miller
Top achievements
Rank 1
Answers by
Dallas Sehlhorst
Top achievements
Rank 1
Adam Miller
Top achievements
Rank 1
Sebastian
Telerik team
JR Go
Top achievements
Rank 1
Share this question
or