0

With Asp.net I have one multiline textbox to take the users' input. I am using a separate webpage to build a print friendly version of that textbox. First I stored the input from the textbox to the session, then I retrieve it from the print friendly page using "Label". I am not using textbox in the print friendly page because I can not control the textbox size when print. My problem is that I the text format in the previous textbox won't keep and all the text goes to one line when I use label to retrieve the text stored in the session. I tried following:

Session["TextBox1"].ToString().Replace(char.ConvertFromUtf32(13),"<br/>")

But it when there are more than two spaces entered in the textbox, it will only show one space in the label.

Any thoughts? Thanks.

Ivancao
  • 11
  • 8
  • show what you have in `theStringYouWantToFormat` and clarify what you mean under *but not other format*. – TarasB Oct 27 '14 at 14:11

1 Answers1

0

Instead of using a label, try using a literal, and have a look at this reference. If you are going to have to display HTML, I would use literals instead.

You need to store the HTML values you have into the session, and bind that to the literal on the print friendly page.

Community
  • 1
  • 1
Mez
  • 4,666
  • 4
  • 29
  • 57
  • Be careful with literals displaying data from user-input though... XSS attacks abound there. – Jon Adams Oct 27 '14 at 14:43
  • The user would like to apply styles when moving his HTML from one page to another - so if it is not a literal, he would need to use a string builder, and render the string to a server control. – Mez Oct 27 '14 at 15:04