I understand that <%=
is for returning a String
I seem to usually use <%#
in my .ascx files.
For example the following works
OnClientClick=<%# String.Format("return confirm('Are you sure you wish to delete barcode ({0})?');", Eval("BARCODE") ) %>
The following does not work
OnClientClick=<%= String.Format("return confirm('Are you sure you wish to delete barcode ({0})?');", Eval("BARCODE") ) %>
<%# indicates there's an evaluation function in there that takes in bound data and examines that data for a column or property in the Eval() function. It is specific to data binding in WebForms.
<%= just expects something that can be converted to a string. It will get confused by EVAL()
And finally there's the new
<%@ in MVC - which takes the string input, and Html encodes it to try to avoid XSS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With