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
236 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

910 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

21 Experts available now in Live!

Get 1:1 Help Now