Tuesday, May 13, 2008

Sample Code (.Net)-1

Most of the time we came across need to get HTML render string for any control. .Net provides a support for this, but is a bit complicated. This function is very helpful when working with AJAX or ICallback event handler

So no worries friends, here is a sample code that will help all of us to get RederHTML string of any control.

private string RenderControlToString(Control c)

StringBuilder sb = new StringBuilder();
System.IO.StringWriter sw = new System.IO.StringWriter(sb);
HtmlTextWriter htmlWriter = new HtmlTextWriter(sw);
return sb.ToString();

call this function wherever required.... cheers