ASP.NET Webform ListView ItemTemplate passing a value to a JavaScript function works correctly if the item_id is numeric. But I get this error if the item_id is alpha-numeric.
Uncaught ReferenceError: pf10001 is not defined
at HTMLAnchorElement.onclick (Products.aspx:1182:163)
<a href="#" class="btn btn-sm btn-success" onclick='<%# "javascript:AddToCart(" + DataBinder.Eval(Container.DataItem, "item_id") + ");return false;" %>'>Add to Cart</a>
function AddToCart(item) {
PageMethods.AddToCart(item, 0, onRequestComplete);
};
Have tried various hidden fields to pass the item_id value without success. But I'm wondering if there's a simple answer to this error.
javascript:scheme in anonclickattribute, so it could just beonclick='<%# "AddToCart(\"" + DataBinder.Eval(Container.DataItem, "item_id") + "\");return false;" %>'>, but it's been a while since I touched a Webform, so this is a guess :).