Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Asp.NET Javascript string, want to pass '(single quotes' within '(single quotes) (http://www.velocityreviews.com/forums/t122291-asp-net-javascript-string-want-to-pass-single-quotes-within-single-quotes.html)

Chris 03-24-2006 06:58 PM

Asp.NET Javascript string, want to pass '(single quotes' within '(single quotes)
 
Hi,
This is a very basic problem, but i am not able to solve it.

msgStr = "<script language =javascript>alert('An exception abc
occured')</script>"
Page.RegisterStartupScript("exception", msgStr)

But if I have want a string like the one shown below, how can I achieve
this ? (Note the single quotes in 'abc')

msgStr = "<script language =javascript>alert('An exception 'abc'
occured')</script>"

Basically, I have a module which creates a string like the msgStr. And
I am passing a string. In this case, I will be passing "An exception
'abc' occured".

But finally, the string becomes as shown in the above line, and gives
some javascript error saying ')' expected.
I tried using 2 single quotes too, but its not working.

TIA..


Oisin 03-24-2006 09:03 PM

Re: Asp.NET Javascript string, want to pass '(single quotes' within '(single quotes)
 
heh, don't you love these problems:

string test = "alert('this is a message \\'test\\' from my script')";

you need to escape the escape character ;)

- Oisin



All times are GMT. The time now is 02:47 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.