What is a good way to redirect console output to asp.net Text-box on Web page? If I have an existing program that has console.Write , do I need to overload the function in Web page Text-box.I have TextBox on web page and I Want to display console.Write output in TextBox. Thank You.
Console.Write
is used to put output on a console. I will not work in Asp.Net. Asp.Net text box control text can be set like textBoxName.Text = "some value"
.
If you would like to write some text to Asp.Net response stream, you may use Response.Write .
public class CustomWriter : TextWriter
{
public override void WriteLine(string value)
{
textBox1.Text += value + Environment.NewLine
}
// ... etc.
}
And use it like this:
Console.SetOut(new CustomWriter());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.