Solved

Assigning multiline to label

Posted on 2006-11-08
5
1,257 Views
Last Modified: 2008-01-09
Hi

I’m fairly new to ASP.NET, I’m using 2.0.

 I am trying to develop a page where the user can enter text into a multi line textbox and then when they click enter the text is stored in a Table in an SQLServer DB.

When the page is reloaded the text that was stored is outputted to a Label.

This works ok except for one small problem when I enter text in the text box which is more than one line IE

"Hello
my
name
is
Graham"

It is displayed in the Label as "Hello my name is Graham"

Does anyone know how to keep the text in the form that it was entered in the textbox when it is displayed in the Label?

Other wise I will not be able to have paragraphs etc, just one long string.

Thanks

0
Comment
Question by:amoran
5 Comments
 
LVL 15

Accepted Solution

by:
mattisflones earned 20 total points
ID: 17897407
The input in a textbox is string, thus displayed as a string when you retrieve the data back.
The linebreaks you see in the textbox are not really there.. call it a malfunck if you want.

One option for handling this is a messy Jscript code, that will not work on lots of browsers, to search your textbox for newlines on submit, but thats a bad solution..

What you need is a wysiwyg editor, that alter your input with <br> tags and so forth, and even allows for real "MSWord" like texthandling..
I can suggest the same editor that i use in all my projects; FredCKs FCKeditor.
http://www.fckeditor.net/
(Be sure to get the ASP.NET addpack aswell as the editor itself! Works like a charm in VS and VSExpress)

Its to say it in one word.. Devine! :-)
0
 
LVL 3

Expert Comment

by:rugu_16
ID: 17900378
No need to do anything. If you want lable to work as multiline then just give fix width like and then lable will contain as many words as it can
and then append at the bottom.

so if u r lable has width = 50px
then "Hello my name is Graham"
will look like

"Hello my name
is Graham"

Rugved
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now