473,398 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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

Mar 24 '06 #1
1 1662
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

Mar 24 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Jakanapes | last post by:
Hi all, I'm looking for a way to scan a block of text and replace all the double quotes (") with single quotes ('). I'm using PHP to pull text out of a mySQL table and then feed the text into...
6
by: G. | last post by:
This is an obvious bug in the String.Replace function: //load a XML string into a document XmlDocument doc = new XmlDocument(); doc.LoadXml("<test id='' />"); //Obtain the string...
3
by: Ben Fidge | last post by:
Is is possible to make just a single page within an ASP.NET application use SSL? I've written an e-commerce application and want to make just the checkout page use SSL for secure transmission. ...
1
by: Keith | last post by:
ADVERTISEMEN Is there any way to display quotes Themselves - within a text strin textbox1.text = "This is a "test" of inserting quotes" I want to actually use quotes within this string...
4
by: vighnesh | last post by:
Hello EveryOne In my project I have to parse a string in Quotes as without Quotes.I tried the following code but it didn't work to me. I again getting the string with Quotes, Can Anybody suggest...
4
by: Erland | last post by:
Hi , I am using Asp.net 1.1 using VB.NET and in the Page_Load() method I am trying to use a Response.Write method as following but I keep getting errors, --------------------------...
2
by: yellowtek | last post by:
Hi, I've got some JavaScript inserted within a PHP echo instruction: <?php> echo " ... javascript ...." <?> This context may be important, I don't know...
2
by: raj | last post by:
Hi all, I'm using this code to import some a .txt files onto a webpage, but I keep seeing single quotes amd double quotes as question marks. Here's the code: <textarea disabled="disabled"...
1
by: Yearwood | last post by:
Hi, I'm basically trying to import a CSV into an ACCESS database. Sample date is shown below: "",10173,"Development Manager - Social Economy Sector","Trust Bank",10153,,"Lolalll Pudd","Meet the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.