I am looking for a way to convert WebForm controls to text.
Is it possible to do this:
TextBox tx = new TextBox();
tx.Text = "test";
string html = tx.HTML();
Where html would be:
<input type="text" value="test"/>
var sb = new StringBuilder();
var htw = new HtmlTextWriter(new System.IO.StringWriter(sb, System.Globalization.CultureInfo.InvariantCulture));
var tx = new TextBox {Text = "test"};
tx.RenderControl(htw);
var html = sb.ToString();
Response.Write(html);
You can use RenderControl()
method
http://msdn.microsoft.com/en-us/library/htwek607(v=vs.80).aspx and get the string in Stream object.