Fco
Fco

Reputation: 195

What mean "the server tag is not well formed", what happen with this button?

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

Answers (2)

Karl Anderson
Karl Anderson

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

James Johnson
James Johnson

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

Related Questions