Problem with a multiline textbox
-
First, the code that i´m using:
//Get url contents
HttpWebRequest hRequest = ((HttpWebRequest)WebRequest.Create(url));
hRequest.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3";
HttpWebResponse resp = (HttpWebResponse)hRequest.GetResponse();//Read contents and output into a textbox
StreamReader reader = new StreamReader(resp.GetResponseStream());
string res = reader.ReadToEnd().ToString();
reader.Close();
textBox1.Text = res;The problem is when i see html source into the textbox it appears bad formatted, dont know if each line of a texbox has a limit of characters and this is why it jumps to another line or what happens. I set the wordwrap property of the textbox to false and added both scrolls bars, but it still bad formatted. Can someone help me? Thanks in advance. :)
-
First, the code that i´m using:
//Get url contents
HttpWebRequest hRequest = ((HttpWebRequest)WebRequest.Create(url));
hRequest.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3";
HttpWebResponse resp = (HttpWebResponse)hRequest.GetResponse();//Read contents and output into a textbox
StreamReader reader = new StreamReader(resp.GetResponseStream());
string res = reader.ReadToEnd().ToString();
reader.Close();
textBox1.Text = res;The problem is when i see html source into the textbox it appears bad formatted, dont know if each line of a texbox has a limit of characters and this is why it jumps to another line or what happens. I set the wordwrap property of the textbox to false and added both scrolls bars, but it still bad formatted. Can someone help me? Thanks in advance. :)
Nothing is wrong with the TextBox. It's just the string you're getting get from the response is not formatted, the textbox outputs it as it is. Most, if not all, compilers and interpreters don't generate formatted response. If you're calling a static webpage, it's just the way it is.
Eslam Afifi
-
Nothing is wrong with the TextBox. It's just the string you're getting get from the response is not formatted, the textbox outputs it as it is. Most, if not all, compilers and interpreters don't generate formatted response. If you're calling a static webpage, it's just the way it is.
Eslam Afifi
Ok, and how can i format the response because if i see the html of google.com into firefox it appears formatted, but into my textbox no. Any idea how can i output the html source formatted into a textbox?? Thanks in advance. :)
-
Ok, and how can i format the response because if i see the html of google.com into firefox it appears formatted, but into my textbox no. Any idea how can i output the html source formatted into a textbox?? Thanks in advance. :)
You'll have to format it yourself. Google and see if someone wrote something you can use or code it yourself. Do NOT use the method where you put the html in xml and output it formatted simply because html can be not well formatted xml.
Eslam Afifi
-
You'll have to format it yourself. Google and see if someone wrote something you can use or code it yourself. Do NOT use the method where you put the html in xml and output it formatted simply because html can be not well formatted xml.
Eslam Afifi
-
Mmmz... using a richtextbox instead a textbox seems that solve the problem. Thanks for the replies. :)
You're welcome. The problem was that the TextBox uses the Environment.NewLine while the RichTextBox uses any of '\n' and '\r' too as line breaks. I didn't know that, thanks for the info.
Eslam Afifi