Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Web
Expertise: Intermediate
Dec 1, 1999

Create Line Breaks in the VID Label Object

The Visual InterDev label script object is a quick way to display text on your Web pages. Trouble is, the data from your recordset may contain line breaks that the label object ignores. The trick to passing line breaks to your label is to use the VBScript Replace() function. It converts the original carriage returns into HTML <BR> tags. In addition, you need to tell the label object to prepare for the <BR> tags and interpret them correctly on the page. If you don't include setDataFormatAs("html"), the label displays the tags instead of line breaks. This code shows the line break technique in action.

 
<SCRIPT ID=serverEventHandlersVBS LANGUAGE=vbscript RUNAT=Server>
Sub Button1_onclick()
Label1.setDataFormatAs("html")
Label1.setCaption(replace(Textbox1.value,chr(10),"<BR>"))
End Sub
</SCRIPT>

One more tip: Rather than using the setDataFormatAs() method in your code, you can check the "Data Contains HTML" box in the Label design-time control.

Ken Cox
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date