asp.net - VerifyRenderingInServerForm : no suitable method found to override C# error -


i writing code export excel gridview. using updatepanel, whole page doesnot loads. so, wrote code :

aspx.cs code

protected void export_click(object sender, eventargs e)     {         gridview gv = (gridview)tbmmastercontentpalceholder.findcontrol("mygridview");         response.clear();         response.addheader("content-disposition", "attachment;filename=suppliers.xls");         response.charset = "";         response.contenttype = "application/vnd.xls";         system.io.stringwriter stringwrite = new system.io.stringwriter();         system.web.ui.htmltextwriter htmlwrite = new htmltextwriter(stringwrite);         gv.rendercontrol(htmlwrite);         response.write(stringwrite.tostring());         response.end();      }     public override void verifyrenderinginserverform(control control) //to prevent export excel error     {     } 

asp code

<asp:button id="btnexport" runat="server" text="  export  " onclick="export_click" /> <triggers>         <asp:postbacktrigger controlid="btnexport" /> </triggers> 

but here, getting error in verifyrenderinginserverform(control control) function. error :

verifyrenderinginserverform(system.web.ui.control)': no suitable method found override 

how solve error ?

i got answer. remove verifyrenderinginserverform(control control) function & use

system.web.ui.htmlcontrols.htmlform form = new system.web.ui.htmlcontrols.htmlform();             controls.add(form);             form.controls.add(gv);             form.rendercontrol(htmlwrite); 

so, our final code be

response.clear();             response.addheader("content-disposition", "attachment;filename=myfile.xls");             response.charset = "";             response.contenttype = "application/vnd.xls";             system.io.stringwriter stringwrite = new system.io.stringwriter();             system.web.ui.htmltextwriter htmlwrite = new htmltextwriter(stringwrite);              system.web.ui.htmlcontrols.htmlform form = new system.web.ui.htmlcontrols.htmlform();             controls.add(form);             form.controls.add(gv);             form.rendercontrol(htmlwrite);             response.write(stringwrite.tostring());             response.end(); 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -