How do i do javascript with ASP.NET?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • baylor

    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_resetPasswo rd.Attributes.A dd("OnClick",
    "javascript:ret urn dConfirm('" + confirmationMes sage + "')");

    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
  • Santhi Maadhaven

    #2
    RE: How do i do javascript with ASP.NET?

    Replace apostrophe with \\' like below..it will work fine..
    confirmationMes sage.Replace("' ","\\'")

    "baylor" wrote:
    [color=blue]
    > 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_resetPasswo rd.Attributes.A dd("OnClick",
    > "javascript:ret urn dConfirm('" + confirmationMes sage + "')");
    >
    > 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[/color]

    Comment

    • baylor

      #3
      RE: How do i do javascript with ASP.NET?

      i love the Internet. So many smart people

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

      -baylor

      Comment

      Working...