Solved

How do i give a string with html and double quotes as a string in VB.net without compiler errors

Posted on 2008-10-15
5
235 Views
Last Modified: 2012-05-05
Hi,

I want to give this as a string and assign it to a variable : '<p style="margin: 0px; font-weight: normal;"> {1}</p>'
i.e
I want to put it between double quotes and assing it to var

dim var as String = ""

Please suggest with code.

thanks
0
Comment
Question by:nirisan
5 Comments
 
LVL 2

Accepted Solution

by:
MasterPage earned 500 total points
ID: 22727474
Hi nirisan,

When you want quotes to appear within the string, enter them twice within the string, such as this:
str = "<p style=""margin: 0px; font-weight: normal;""> {1}</p>"
0
 
LVL 8

Expert Comment

by:rlh68
ID: 22727499

Dim str as String
str = "'<p style=""margin: 0px; font-weight: normal;""> {1}</p>'"
0
 
LVL 8

Expert Comment

by:rlh68
ID: 22727504
FYI, MasterPage I think nirisan needs the opening and ending single quote in the string too.
0
 

Author Comment

by:nirisan
ID: 22727569
thanks,

I am compiling without errors but it renders as text on the page.
Here is how i gave it with 4 double quotes per double quote. But how do i set it for the browser not to display as html as it is a property for the style. Below are tow variables i am using.

var = "'<p style=""""margin: 0px; font-weight: normal;""""> {1}</p>'"
var1 = "'<p style=""""margin: 0px; font-weight: normal;""""><img src=""""http://images.mysite.com/static/images/mark.gif"""" style=""""margin-left: -8px;"""">{1}</p>'"

0
 
LVL 8

Expert Comment

by:dampsey
ID: 22728357
how do you add this variable in to the page?
if you are setting innerText of some element then change it to innerHTML
or add as LiteralControl
this.Page.Contols.Add(new LiteralControl(var1))
 
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
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…

708 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

16 Experts available now in Live!

Get 1:1 Help Now