Results 1 to 1 of 1

Thread: Apostrophes in databound data

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2002
    Posts
    235

    Apostrophes in databound data

    This might be a JavaScript problem, but I'm not sure, so I'm taking a bet on those who know ASP.NET, know JavaScript too....

    I'm calling a javascript function that has apostrophes in the arguement strings:

    Code:
    <a href="JavaScript:alert('Mervyn's');">Mervyn's</a><br>
    Of course in this example, I could escape the ', to

    Code:
    alert('Mervyn\ 's') //without the space, of course
    but of course the problem isn't that simple. I'm databinding the arguement like this:

    Code:
    <a href="JavaScript:alert('<%#DataBinder.Eval (Container.DataItem, "StoreName")%>');">
       <%#DataBinder.Eval(Container.DataItem, "StoreName")%>
    </a>
    This doesn't work when there's an apostrophe in the store name. It seems that there would be a way around this, but I haven't figured it out yet. How can I make sure apostrophe's in StoreName don't break my code?

    Thanks.
    Last edited by csnyder; Apr 23rd, 2003 at 09:02 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width