HttpTextWriter object

Posted by Riyu under Regular Expressions on 4/12/2010 | Views : 1765 | Status : [Member] | Replies : 1
Can anyone tell me ,what is difference between Response.Output.Write(string sb)

and

An object of Html32TextWriter which calls write method output.Write(string sb2); .
ex :
StringBuilder SBOut = new StringBuilder();
StringWriter st=new StringWriter(SBOut);
Html32TextWriter output=new Html32TextWriter(st);
SBOut.Append(c1 + "<table>" + str);
SBOut.Append( c1 + "<tr>" + str);
SBOut.Append(c1+ "<td>" + str);
SBOut.Append(c1+ "Username: " + str);
SBOut.Append(c1+ "<input type='reset'/>" + str);
SBOut.Append(c1+ "</td>" + str);
SBOut.Append(c1+ "</tr>" + str);
SBOut.Append(c1+ "</table>" + str);
string sb2 = SBOut.ToString();
output.Write(sb2);

and why I am not getting the desirable Html output in web-browser while writting above code.




Responses

Posted by: SurajRane on: 4/12/2010 [Member] Starter

Up
0
Down
hi Riyu,

i dont know what is c1. but you can write your code in page.Render method then it will work.

As follows

protected override void Render(HtmlTextWriter writer)

{
base.Render(writer);


StringBuilder SBOut = new StringBuilder();
string str = string.Empty;

SBOut.Append("<table>" + str);
SBOut.Append( "<tr>" + str);
SBOut.Append( "<td>" + str);
SBOut.Append( "Username: " + str);
SBOut.Append( "<input type='reset'/>" + str);
SBOut.Append( "</td>" + str);
SBOut.Append( "</tr>" + str);
SBOut.Append( "</table>" + str);
string sb2 = SBOut.ToString();
writer.Write(sb2);

}




Riyu, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response