Click here to Skip to main content
15,909,466 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All
i am getting A page can have only one server-side Form tag. on exporting grid view in excel in asp.net. grid view is on content page with master page and master page has only one form tag.
for exporting i have done the following code.


Response.Clear();
               Response.ContentType = "application/vnd.xls";
               Response.AddHeader("content-disposition",
                       "attachment;filename=subscribers.xls");

               StringWriter swriter = new StringWriter();
               HtmlTextWriter hwriter = new HtmlTextWriter(swriter);

               HtmlForm frm = new HtmlForm();
               this.gvViewSearch.Parent.Controls.Add(frm);
               frm.Attributes["runat"] = "server";
               frm.Controls.Add(this.gvViewSearch);
               frm.RenderControl(hwriter);

               Response.Write(swriter.ToString());
               Response.End();


C#
public override void VerifyRenderingInServerForm(Control control)
        {
        }



plz help me.
Posted

Perhaps the code you have written here is under code behind file of the content page. So think that, here you have created a server side form and there is server side form on Master page. so when you try to render this page then this form loads in another form. which is not allowed. Does this make sense?
 
Share this answer
 
v2
Comments
Umashankar Yadav 16-Jul-12 9:18am    
not getting solution
JakirBB 16-Jul-12 9:35am    
Though I'm not sure whether it'll work or not (don't blame me), I can devise a way. Just try it. And let me know whether its works or not.
Assign a ID to your MasterPage Form [ie. <form runat="server" id="TestForm">]

Now use this form in you content form instead of creating a new one.
[ie. this.Master.FindControl("TestForm")]
Nabil1404 24-Aug-13 5:44am    
how to use it?
Umashankar Yadav 16-Jul-12 11:06am    
thanks now it working
Try this:
Comment out the following:
C#
//public override void VerifyRenderingInServerForm(Control control)
//{
//}

Compiler might be getting confused because of it. See if this works.
 
Share this answer
 
Comments
Umashankar Yadav 16-Jul-12 11:17am    
Sorry!!! its not working...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900