The statement that is (probably) not working in your MVC app is the call to <%# DataBinder.Eval(...) %>
. In MVC, I assume you have a for loop or something that iterates over your model? Maybe something like this?*
<% foreach(var item in Model)
{ %>
<a href="#" onclick='openUserSavedListDetailsPopUp(<%: item.OrderId %>)>hello</a>
<% } %>
I'd also recommend using some type of javascript library, for example jQuery, to hook up the onclick events instead of having the javascript inline. For this particular case jQuery might not add much value to your application (except that your code will probably be cleaner), but it really helps for anything from ajax calls to DOM manipulation and animation.
And finally, you should have a fallback for browsers that don't support (or have disabled) javascript. The easy way is to change your link to this:
<a href="urltothepopupcontentpage.html?id=<%: item.OrderId %>" onclick='openUserSavedListDetailsPopup(<%: item.OrderId %>); return false'>hello</a>
The call to return false
will ensure that if your script can run, it stops the default action (following the link).
*) Note: using <%: ... %>
instead of <%= Html.Encode(...) %>
requires that you use ASP.NET 4. If you are running .NET 3.5, you use the =
sign as usual.