MyHeadHurts
MyHeadHurts

Reputation: 1562

quotes in vb.net links

I want to make a link from what the user filepath that is given from an openfiledialog. But I can't get all the quotes in the right places

   DOCTextBox.Text = "<a href=" & OpenFileDialog1.FileName &  "target=_"blank">" & TitleTextBox.Text & "</a>"

Upvotes: 0

Views: 347

Answers (4)

SLaks
SLaks

Reputation: 887837

In order to put a " in a VB.Net string literal, you need to write "".

For example:

   "<a href=""" & HttpUtility.HtmlAttributeEncode(OpenFileDialog1.FileName) _
 & """target=_""blank"">" & HttpUtility.HtmlEncode(TitleTextBox.Text) & "</a>"

Upvotes: 2

Achilles
Achilles

Reputation: 11319

You can use triple quotes such as """

Upvotes: 0

JaredPar
JaredPar

Reputation: 755219

It sounds like you're trying to add quotes into the final string produced from the expression. In order to do that use a pair of double quotes "". For example

"<a href=""" & OpenFileDialog1.FileName & """></a>"

Upvotes: 0

shamazing
shamazing

Reputation: 730

DOCTextBox.Text = "<a href=""" & OpenFileDialog1.FileName & """ target=_""blank"">" & TitleTextBox.Text & "</a>"

Upvotes: 1

Related Questions