String concact problem

D

David C

I have an asp.net page that is adding a javascript onclick event by adding
an attribute (see below). The problem is that when the file name (shown as
strNewFile) has a single quote in the name (e.g. David's Document.doc) then
the javascript function fails. I assume it is a string concat problem but
have been unable to solve it. Any help is appreciated.

David

varControl = e.Item.FindControl("LBtnEmailDoc")
varControl.Attributes.Add("onclick", "openOutlook('\\\\" &
strNewFile & "')")
 
M

Milosz Skalecki [MCAD]

Howdy,

varControl = e.Item.FindControl("LBtnEmailDoc")
varControl.Attributes.Add("onclick", "openOutlook('\\\\" &
strNewFile.Replace("'", "\'") & "')")

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top