Copied to clipboard

Flag this post as spam?

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

  • Siw Ørnhaug 130 posts 109 karma points
    Sep 14, 2012 @ 14:11
    Siw Ørnhaug

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

    Hello everybody,

    I know why I'm getting the error message above but not how to get around it. I've made many gridview reports outside of Umbraco with a simple push to Excel by streaming and using the RenderControl method. I've always put the public override void VerifyRenderingInServerForm(Control control) onto the form and everything works fine. Easy peasy.

    But now I'm trying this for the first time in a Umbraco template with a user control. And here the Verify RenderingInServerForm method is just not recognized - it seems. How should I do this?

    The site is in Umbraco 4.7.2, .net 4.0

    Suggestions are very much appreciated!


  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Sep 14, 2012 @ 17:01
    Jan Skovgaard

    Hi Siw

    Sounds like you're missing a <form runat="server"> around your content in your master-template in order to make this work - could you perhaps post a snippet of what your master template looks like?


  • Siw Ørnhaug 130 posts 109 karma points
    Sep 18, 2012 @ 09:27
    Siw Ørnhaug

    Hi there Jan, excuse me for responding late. I'm back at the case now. 
    I'm not missing a form runat=server tag. It's not in the master template as several of the subtemplates have need of such a tag.
    I've made a simple user control that reports data from subnodes of a doctype node with the pdcalendar attached. The report control contains a gridview and I've put it in a small template on a separat reporting page. It works fine until I click the button that renders the gridview to a stream with content type application/
    Then I get this:


    Server Error in '/' Application.

    Control 'ContentPlaceHolderDefault_tmpMainContentPlaceHolder_RapportKursdeltakere_3_gvRapport' of type 'GridView' 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_tmpMainContentPlaceHolder_RapportKursdeltakere_3_gvRapport' of type 'GridView' 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_tmpMainContentPlaceHolder_RapportKursdeltakere_3_gvRapport' of type 'GridView' must be placed inside a form tag with runat=server.]
       System.Web.UI.Page.VerifyRenderingInServerForm(Control control) +11271910
       System.Web.UI.WebControls.GridView.Render(HtmlTextWriter writer, Boolean renderPanel) +75
       kbrKurs.RapportKursdeltakere.btnExcel_Click(Object sender, EventArgs e) +725
       System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +154
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3691


    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1 

    After reading your answer I tried moving the server side form tag from around the macro in the report template and into the ascx form itself. It didn't make any differende. 

    The code of the click event: 

    protected void btnExcel_Click(object sender, EventArgs e)
                Response.ContentType = "application/";
                Response.AddHeader("Content-Disposition", "attachment; filename=Kursdeltakere_" + DateTime.Today.ToShortDateString() + ".xls");
                Response.ContentEncoding = System.Text.Encoding.Unicode;
                StringBuilder sb = new StringBuilder();
                StringWriter tw = new StringWriter(sb);
                HtmlTextWriter hw = new HtmlTextWriter(tw);

    So I've tried the usual remedy: putting in an override f the verifyRenderingInServerForm. But when I do this in my VS project it won't compile, the error is:

    Error1'kbrKurs.RapportKursdeltakere.VerifyRenderingInServerForm(System.Web.UI.Control)': no suitable method found to overrideC:\Users\Siw\PROSJEKTER\KBR\kbrKurs\kbrKurs\RapportKursdeltakere.ascx.cs14330kbrKurs

    Do you have other suggestions?
    I'm hoping :)


  • Sean Sachen 31 posts 77 karma points
    Jun 11, 2013 @ 17:51
    Sean Sachen

    Did you ever get this resolved?  I'm facing a similar issue when trying to export to PDF.  



  • Siw Ørnhaug 130 posts 109 karma points
    Jun 11, 2013 @ 20:06
    Siw Ørnhaug

    No, I'm sorry, I convinced my customer he could live without it, I didn't have more time to spend on the issue.

    But I sure would like know how to handle this - good luck!



  • Sean Sachen 31 posts 77 karma points
    Jun 11, 2013 @ 20:18
    Sean Sachen

    HA HA!  Nice.

    Basically what I ended up doing was build out the html "manually".  I was trying to get the html from a gridview to be able to send that to a PDF.  The error forced me into a corner to where I had to come up with something.  It's not optimal, by any stretch, but it gets us by.

    I appreciate your response.



Please Sign in or register to post replies

Write your reply to: