Server Error in '/' Application.
RegisterForEventValidation can only be called during Render();
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.InvalidOperationException: RegisterForEventValidation can only be called during Render();
Source Error:
Line 139: Dim sw As New System.IO.StringWriter()
Line 140: Dim htw As New HtmlTextWriter(sw)
Line 141: GridView2.RenderControl(htw)
Line 142: Response.Write(sw.ToString())
Line 143: Response.[End]()
|
and that's code behind :
Protected Sub ibtnNew_Click(sender As Object, e As ImageClickEventArgs) Handles ibtnNew.Click
Response.ClearContent()
Response.AddHeader("content-disposition", "attachment; filename=Deal_Report_And_Account.xls")
Response.ContentType = "application/excel"
Dim sw As New System.IO.StringWriter()
Dim htw As New HtmlTextWriter(sw)
GridView1.RenderControl(htw)
Response.Write(sw.ToString())
Response.[End]()
End Sub
Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
'Tell the compiler that the control is rendered
'explicitly by overriding the VerifyRenderingInServerForm event.
End Sub
Protected Sub ImageButton1_Click(sender As Object, e As ImageClickEventArgs) Handles ImageButton1.Click
Response.ClearContent()
Response.AddHeader("content-disposition", "attachment; filename=Deal_Report_And_Account_Staff.xls")
Response.ContentType = "application/excel"
Dim sw As New System.IO.StringWriter()
Dim htw As New HtmlTextWriter(sw)
GridView2.RenderControl(htw)
Response.Write(sw.ToString())
Response.[End]()
End Sub
please solve an error.
Thanks