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.