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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

770 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