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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

821 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