473,772 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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>ale rt('An exception abc
occured')</script>"
Page.RegisterSt artupScript("ex ception", 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>ale rt('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 1682
heh, don't you love these problems:

string test = "alert('thi s 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
36168
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 a javascript function called by onClick. The problem is that the text may contain single or double quotes, which screws up the javascript. I eliminated the single quote problem by running the text through addslashes, but the double quotes are a...
6
22209
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 again...Converts my '' to ""...strange, but ok. String strXML = doc.OuterXml; //trying to convert back the single quotes to double quotes
3
1992
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. If it's not possible to do this, and I have to put the checkout page in it's own application, what's the best way to pass data between the two applications? If at all possible, I'd like to avoid using querystrings.
1
1357
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 around the wor test - but the program picks this up as me ending the string and the obviously does not like the work test just sitting there and then i
4
2492
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 me where I went wrong? Thanks in advance. code:
4
2084
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, -------------------------- Response.Write("<td><a href=""SecondPage.aspx?ID="+counter.ToString()+" "" " >Read</a></td>" --------------------------
2
19078
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
1837
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" name="textarea2" cols="70" rows="7" wrap="virtual"><?php addslashes(include("../license/license.txt")); ?> </textarea>
1
4922
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 requirements of Structured Finance & Relationship Teams for "transaction support" at all times, ensuring appropriate analysis and clarity in respect of required/request","",09-Sep-2008,42000,38000,"+ LTA +...
0
9619
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10103
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9911
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8934
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.