1

The below code works but I am not sure how?

OnClientClick='<%# CreateConfirmation(Eval("EventName"),DataBinder.Eval(Container.DataItem, "EventDate", "{0:ddd, d MMM}")) %>'

Public Function CreateConfirmation(ByVal EventName As String, ByVal EventDate As String) As String Return String.Format("return confirm('Are you sure you wish to register for {0} on {1} ?');", EventName, EventDate) End Function

I have read that <%# %> is a databinding expression, but overhere we are not directly data-bidning (infact returining value from the function CreateConfirmation) and I also thought that it should work with <%= %> but it gives JavaScript error message i.e. Illigal XML character pointing to =

Please could you clarify as to why is this?

Many Thanks.

3 Answers 3

1

This question is very precisely answered in an exisiting post:

Why will <%= %> expressions as property values on a server-controls lead to a compile errors?

Sign up to request clarification or add additional context in comments.

Comments

0

You can call any code inside the <%#. The Eval bit is the piece that makes it relate to the row/object in the datasource.

Comments

0

You are still binding the returned string to the property. You can only use <%=%> with inline HTML. You have to use <%#%> when binding to a contols property.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.