473,657 Members | 2,395 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

can ASP.NET properly parse a string to pass to JavaScript?

PJ6
I can probably code this up manually myself but I'd prefer to use a built-in
method that I'm sure exists... I have a message box client-side control
(thanks, Steve Orr) that uses the JavaScript alert() method to pass text to
a user in a dialogue box. Often I have messages containing text that
JavaScript doesn't like, like single quote characters. Does ASP.NET have a
method to parse text for JavaScript? Server.HTMLEnco de doesn't seem to do
the trick.

TIA,
Paul
Dec 2 '05 #1
2 1721
yes, but its private, so you can not call it. here is a simple one:

public static string JscriptQuote(st ring s)
{
s = s.Replace("'", "\\'");
s = s.Replace("\n", "\\n");
s = s.Replace("\r", "");
return "'" + s + "'";
}

-- bruce (sqlwork.com)
"PJ6" <no****@nowhere .net> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
I can probably code this up manually myself but I'd prefer to use a
built-in method that I'm sure exists... I have a message box client-side
control (thanks, Steve Orr) that uses the JavaScript alert() method to pass
text to a user in a dialogue box. Often I have messages containing text
that JavaScript doesn't like, like single quote characters. Does ASP.NET
have a method to parse text for JavaScript? Server.HTMLEnco de doesn't seem
to do the trick.

TIA,
Paul

Dec 2 '05 #2
PJ6
Private? They bent over backwards to give us methods for everything else.
That just doesn't make any sense to me.

Oh well. Thanks for the info.

Paul

"Bruce Barker" <br************ ******@safeco.c om> wrote in message
news:ek******** *****@TK2MSFTNG P15.phx.gbl...
yes, but its private, so you can not call it. here is a simple one:

public static string JscriptQuote(st ring s)
{
s = s.Replace("'", "\\'");
s = s.Replace("\n", "\\n");
s = s.Replace("\r", "");
return "'" + s + "'";
}

-- bruce (sqlwork.com)
"PJ6" <no****@nowhere .net> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
I can probably code this up manually myself but I'd prefer to use a
built-in method that I'm sure exists... I have a message box client-side
control (thanks, Steve Orr) that uses the JavaScript alert() method to
pass text to a user in a dialogue box. Often I have messages containing
text that JavaScript doesn't like, like single quote characters. Does
ASP.NET have a method to parse text for JavaScript? Server.HTMLEnco de
doesn't seem to do the trick.

TIA,
Paul


Dec 2 '05 #3

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

Similar topics

6
1796
by: Michael Hill | last post by:
I have this large array with dates in it. There is a function that sorts it for me. The only problem is that in order for it to get sorted properly I have to sort it AlphaNumerically first using this first: list_b_array = cf_array.sort(function(a,b){return compareAlpha(a,b);}); then this:
1
2014
by: Charlie T | last post by:
hello, I need a little guidance here... I am tring to parse out an XML file, but with some restrictions. here is my XML FILE: ---------XML----------- <XML> <Cam name="01"> <loc>Newport</loc>
6
6080
by: nate | last post by:
Hello, Does anyone know where I can find an ASP server side script written in JavaScript to parse text fields from a form method='POST' using enctype='multipart/form-data'? I'd also like it to parse the filename. <form name='form1' method='POST' enctype='multipart/form-data' action='sub.asp'> <input type='text' name='title1' value='value1'> <input type='file' name='file1'>
3
24390
by: Mark | last post by:
How do you parse a currency string to a decimal? I'd like to avoid having to parse the number out, removing the $ manually. That sounds like a hack. There are times that this string will be currency and others when it will be a text integer or decimal. //This bombs because of the string having an improper format. Decimal.Parse("$9,200.00") Thanks in advance! Mark
3
20639
by: aaronwmail-usenet | last post by:
Ok, I've seen many examples of javascript parsing an XML document retrieved from a file indicated by a URL. The problem is I need to parse (usually small) xml *strings* embedded in the javascript program or generated locally, and I can't find any way to do this exposed (even though some internal part of the engine clearly is capable of doing it). Am I missing something?
9
14090
by: Python.LeoJay | last post by:
Dear all, i need to parse billions of numbers from a file into float numbers for further calculation. i'm not satisfied with the speed of atof() function on my machine(i'm using visual c++ 6). so i wonder is there any faster way to parse string(char array) into float number.
10
3191
by: Michael B. Trausch | last post by:
Alright... I am attempting to find a way to parse ANSI text from a telnet application. However, I am experiencing a bit of trouble. What I want to do is have all ANSI sequences _removed_ from the output, save for those that manage color codes or text presentation (in short, the ones that are ESChttp://fd0man.theunixplace.com/Tmud.tar which contains the code in question. In short, the information is coming in over a TCP/IP socket that...
3
8904
by: rupinderbatra | last post by:
Hello everyone, I am using a regular expression to parse a text string into various parts -- for ex: string "How do you do" will be changed to array with all the words and white spaces. I am using the following code (which has been copied from internet) <html> <body> <script type="text/javascript">
0
8394
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
8825
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...
1
8503
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
7327
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
5632
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
4152
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
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
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.