I want to get the GridView's html code before page render. I just used GridView.RenderControl() method. The gridview was inside an update panel.
----------Here Comes My Code---------------
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
GridView gv = new GridView(); //Dummy data gridview
gv.DataSourceID = "SqlDataSource1";
gv.DataBind();
try
{
gv.RenderControl(htmlWrite);
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
When you run the above code following error will be generated
Error:
sys.webforms.PageRequestManagerParserException: The message received from the server could not be parsed.Common causes for this error are when the response is modified by calls to Response.Write ,response filters ,http modules or server trace is enabled
Details:Error Parsing near "%Pdf-1.4" %[] []
I solved the issue with the below code
<Triggers >
<ajax:PostBackTrigger ControlID ="btnPrint" />
</Triggers>
----------Here Comes My Code---------------
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
GridView gv = new GridView(); //Dummy data gridview
gv.DataSourceID = "SqlDataSource1";
gv.DataBind();
try
{
gv.RenderControl(htmlWrite);
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
When you run the above code following error will be generated
Error:
sys.webforms.PageRequestManagerParserException: The message received from the server could not be parsed.Common causes for this error are when the response is modified by calls to Response.Write ,response filters ,http modules or server trace is enabled
Details:Error Parsing near "%Pdf-1.4" %[] []
I solved the issue with the below code
<Triggers >
<ajax:PostBackTrigger ControlID ="btnPrint" />
</Triggers>
No comments:
Post a Comment