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


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

dim var as String = ""

Please suggest with code.

Who is Participating?
MasterPageConnect With a Mentor Commented:
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>"

Dim str as String
str = "'<p style=""margin: 0px; font-weight: normal;""> {1}</p>'"
FYI, MasterPage I think nirisan needs the opening and ending single quote in the string too.
nirisanAuthor Commented:

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="""""""" style=""""margin-left: -8px;"""">{1}</p>'"

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))
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.