Getting HTML string of Panel in codebehind
-
Hello, I am using a panel control on page. I want a html of the pannel control in codebehind. Thanks in Advance Regards, Milind
-
Hello, I am using a panel control on page. I want a html of the pannel control in codebehind. Thanks in Advance Regards, Milind
Hi, what are you trying to achieve? please clarify
himanshu
-
Hi, what are you trying to achieve? please clarify
himanshu
I am trying to get HTML containing in the Panel object (the panel is contaning tables and gridview)
-
Hello, I am using a panel control on page. I want a html of the pannel control in codebehind. Thanks in Advance Regards, Milind
milindchavan12 wrote:
I want a html of the pannel control in codebehind.
You want the rendered HTML output of the panel, right? Try something like
public string GetControlRenderedOutput(Control control)
{
StringBuilder builder = new StringBuilder();
StringWriter writer = new StringWriter(builder);
HtmlTextWriter htmlWriter = new HtmlTextWriter(writer);
control.RenderControl(htmlWriter);
return builder.ToString();
}Try passing your panel's object to this method. :)
Navaneeth How to use google | Ask smart questions
modified on Monday, June 15, 2009 8:42 AM
-
milindchavan12 wrote:
I want a html of the pannel control in codebehind.
You want the rendered HTML output of the panel, right? Try something like
public string GetControlRenderedOutput(Control control)
{
StringBuilder builder = new StringBuilder();
StringWriter writer = new StringWriter(builder);
HtmlTextWriter htmlWriter = new HtmlTextWriter(writer);
control.RenderControl(htmlWriter);
return builder.ToString();
}Try passing your panel's object to this method. :)
Navaneeth How to use google | Ask smart questions
modified on Monday, June 15, 2009 8:42 AM
Thank you, It works
-
milindchavan12 wrote:
I want a html of the pannel control in codebehind.
You want the rendered HTML output of the panel, right? Try something like
public string GetControlRenderedOutput(Control control)
{
StringBuilder builder = new StringBuilder();
StringWriter writer = new StringWriter(builder);
HtmlTextWriter htmlWriter = new HtmlTextWriter(writer);
control.RenderControl(htmlWriter);
return builder.ToString();
}Try passing your panel's object to this method. :)
Navaneeth How to use google | Ask smart questions
modified on Monday, June 15, 2009 8:42 AM
Ohh Problem .... It is giving me error on control.RenderControl(htmlWriter) line. public string GetControlRenderedOutput(Control control) { StringBuilder builder = new StringBuilder(); StringWriter writer = new StringWriter(builder); HtmlTextWriter htmlWriter = new HtmlTextWriter(writer); control.RenderControl(htmlWriter); return builder.ToString(); } Error : RegisterForEventValidation can only be called during Render();
-
Ohh Problem .... It is giving me error on control.RenderControl(htmlWriter) line. public string GetControlRenderedOutput(Control control) { StringBuilder builder = new StringBuilder(); StringWriter writer = new StringWriter(builder); HtmlTextWriter htmlWriter = new HtmlTextWriter(writer); control.RenderControl(htmlWriter); return builder.ToString(); } Error : RegisterForEventValidation can only be called during Render();