Reputation: 195
This is my button:
<asp:LinkButton ID="lnkButton"
OnClientClick="showEnroll(this,true,'<%# Eval("EventId") %>'); return false"
runat="server" CommandArgument='<%# Eval("EventId") %>' />
This is the error: "The server tag is not well formed"
Upvotes: 0
Views: 327
Reputation: 34846
In your binding (i.e. RowDataBound
for a grid view), add the logic like this:
// Attempt to find the control
var theLinkButton = e.Row.FindControl("lnkButton") as LinkButton;
// Only try to use the control if it was actually found
if(theLinkButton != null)
{
// Grab the event ID from wherever here
// Set the OnClientClick attribute here
theLinkButton.Attributes.Add("onClientClick",
"showEnroll(this,true,'" + theEventId.ToString() + "'); return false");
}
Upvotes: 1
Reputation: 46047
It means that the markup is invalid, and it's because of the inline databinding expressions. Something like this should work better:
OnClientClick='<%# string.Format("showEnroll(this, true, \'{0}\'", Eval("EventId")) %>'
Note: I have not validated the above code. It is intended to illustrate a concept, and may need tweaking.
Upvotes: 1