Display formatted text nicely?

Headings, linebreaks, bold etc. How to display?

Page 1 of 1

2 Replies - 9492 Views - Last Post: 18 March 2010 - 08:50 PM Rate Topic: -----

#1 oldSwede  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 3
  • View blog
  • Posts: 459
  • Joined: 08-January 16

Display formatted text nicely?

Posted 18 March 2010 - 05:23 AM


I'm developing a site in Visual Web Developer 2008 with VB code behind. The pages have fixed size with headers and footers and a "menu" on the left side. Thus the content area has fixed size.

One of the problems I'm having is how to display text nicely. There is a lot of text on my site. I change it quite often so I store it in a database and read it into a literal control that resides in a table in the content area. This way I can store stuff like <b>some text here</b> and have it show up formatted, which is nice.

Now, if the text is too long it will "spill" out of the content area and go on below it, messing up my nice :) page design. How to handle this? I could use a multiline textbos but then I'd loose the ability to format the text and use headings and stuff. I whish I had a textbox that had all the features of the litera control, or a literal control that could scroll text.

Ideas, suggestions please?


Is This A Good Question/Topic? 0
  • +

Replies To: Display formatted text nicely?

#2 ruslan40  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 34
  • Joined: 13-September 08

Re: Display formatted text nicely?

Posted 18 March 2010 - 07:55 PM

If I understood your problem correctly, you can try to wrap your asp:literal into a div with a static height (to match the page design) and add an overflow-y: scroll; style attribute to the div... This will prevent the text from going below its intended "space", and will give you a scrollbar in that area if it does overflow.

So, if your "content area" is 400 pixels tall, then your code would look like this:

<div style="height: 400px; overflow-x: auto; overflow-y: scroll;">
  <asp:Literal runat="server" ...... />

This post has been edited by ruslan40: 18 March 2010 - 07:58 PM

Was This Post Helpful? 1
  • +
  • -

#3 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 421
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: Display formatted text nicely?

Posted 18 March 2010 - 08:50 PM

The DIV is an excellent suggestion. However, you needn't bother with the Literal control inside of it. Just write directly into the DIV.

If you add the 'runat="server"' tag and give your DIV and id. Then you can access it directly from the code behind and write the text, with html formatting, directly into it.

<div id="divContent" runat="server" style="overflow-x: auto; overflow-y: scroll;">

divContent.InnerHTML = "<b>some text here</b>"

Just a suggestion. Either way will work just fine.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1