Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Formatting Multiline Text

Reply
Thread Tools

Formatting Multiline Text

 
 
=?Utf-8?B?T3dlbiBSaWNoYXJkc29u?=
Guest
Posts: n/a
 
      08-23-2006
I have read several posts regarding formatting multiline text for rendering
becuase vbCrLf needs to be converted to <br/> tags, and i need to do the
same. My question is the best way to achieve this - One of my pages is using
a detailview control on a Description datafield; what would be the best way
for me to format the Description field before its rendered?

Regards
Owen
 
Reply With Quote
 
 
 
 
David Wier
Guest
Posts: n/a
 
      08-23-2006
do a replace on the Textbox text
String.Replace(vbcrlf, "<br>")
--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com



"Owen Richardson" <(E-Mail Removed)> wrote in
message news:(E-Mail Removed)...
> I have read several posts regarding formatting multiline text for

rendering
> becuase vbCrLf needs to be converted to <br/> tags, and i need to do the
> same. My question is the best way to achieve this - One of my pages is

using
> a detailview control on a Description datafield; what would be the best

way
> for me to format the Description field before its rendered?
>
> Regards
> Owen



 
Reply With Quote
 
 
 
 
=?Utf-8?B?T3dlbiBSaWNoYXJkc29u?=
Guest
Posts: n/a
 
      08-23-2006
Hi... I dont think i was really clear - i understand how to do the string
replace but not where. In my example i was displaying a detailview control
bound to my database, and trying to render the description field; Looking
through the code i dont know where its appropriate to run this function; I am
new to asp.net - I have created an template for my description field within
it i have the following code:

<asp:Label ID="Label2" runat="server" Text='<%# Bind("description")
%>'></asp:Label>

and i literally dont know what to do with it.... do I have to do something
create a prerender function for Label2? if so how do i reference
label2.Text....? Alternatively do i have another event on the DetailView
control the page that i have to trap? I want to just change this one field in
the most simple clean way possible.

Kind Regards
Owen

"David Wier" wrote:

> do a replace on the Textbox text
> String.Replace(vbcrlf, "<br>")
> --
> David Wier
> MVP/ASPInsider
> http://aspnet101.com
> http://aspexpress.com
>
>
>
> "Owen Richardson" <(E-Mail Removed)> wrote in
> message news:(E-Mail Removed)...
> > I have read several posts regarding formatting multiline text for

> rendering
> > becuase vbCrLf needs to be converted to <br/> tags, and i need to do the
> > same. My question is the best way to achieve this - One of my pages is

> using
> > a detailview control on a Description datafield; what would be the best

> way
> > for me to format the Description field before its rendered?
> >
> > Regards
> > Owen

>
>
>

 
Reply With Quote
 
Todd
Guest
Posts: n/a
 
      09-19-2006
There's several ways to do this, but try this. Add a function in the
code behind, something like...


Function MyFunc(MyVal as String) as String
return Replace(MyVal, vbcrlf, "<br>")
End Function

Then on the aspx page itself, change your bind tag to....

<asp:Label ID="Label2" runat="server" Text='<%#
MyFunc(Eval("description") )%>'></asp:Label>

Or if you have other things to convert, build a conversiob class and
call the class from the function.

HTH

Todd

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to define a variable to hold a multiline text input in perl from html multiline textbox dale zhang Perl Misc 8 11-30-2004 06:53 AM
Style sheet formatting not working with Multiline text box. Chris ASP .Net 2 10-26-2004 11:35 AM
Regularexpression validator on multiline text box Stephan Bour ASP .Net 2 10-28-2003 09:42 PM
Different fonts in multiline text box... Michael Tanner ASP .Net 1 07-25-2003 05:55 PM
how to limit user input into the multiline text box???? cw ASP .Net 1 06-27-2003 11:57 AM



Advertisments