473,324 Members | 1,856 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,324 software developers and data experts.

How do i do javascript with ASP.NET?

i have an ASP.NET application that displays confirmation prompts using
javascript. The text of these messages comes from a string resource file. The
script is attached to the button. Code is similar to this:

btn_resetPassword.Attributes.Add("OnClick",
"javascript:return dConfirm('" + confirmationMessage + "')");

This works great unless the message contains an apostrophe. User a word like
"user's" and the routine never runs. No error (other than a browser
notification of "unexpected )"), just doesn't run

We have tried used \, html encoding, double quotes and doubling up the
apostrophe. None of it works. Using the \ does work if we take it out of C#
and put it in a separate javascript file but if we do that we no longer have
access to our string resource file so that's not going to fly

There's got to be a way to do this (i'm an eternal optimist) but we're run
out of ideas as to how
Jul 28 '05 #1
2 1441
Replace apostrophe with \\' like below..it will work fine..
confirmationMessage.Replace("'","\\'")

"baylor" wrote:
i have an ASP.NET application that displays confirmation prompts using
javascript. The text of these messages comes from a string resource file. The
script is attached to the button. Code is similar to this:

btn_resetPassword.Attributes.Add("OnClick",
"javascript:return dConfirm('" + confirmationMessage + "')");

This works great unless the message contains an apostrophe. User a word like
"user's" and the routine never runs. No error (other than a browser
notification of "unexpected )"), just doesn't run

We have tried used \, html encoding, double quotes and doubling up the
apostrophe. None of it works. Using the \ does work if we take it out of C#
and put it in a separate javascript file but if we do that we no longer have
access to our string resource file so that's not going to fly

There's got to be a way to do this (i'm an eternal optimist) but we're run
out of ideas as to how

Jul 29 '05 #2
i love the Internet. So many smart people

Yup, that did it. In retrospect, i feel dumb for not thinking of this. Thanks!

-baylor
Jul 29 '05 #3

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

Similar topics

0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.