String concact problem

  • Thread starter Thread starter David C
  • Start date Start date
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 & "')")
 
Howdy,

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

HTH
 
Back
Top