[英]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" 这是错误:“服务器标记格式不正确”
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.
它旨在说明一个概念,可能需要进行调整。
In your binding (ie RowDataBound
for a grid view), add the logic like this: 在绑定中(即网格视图的
RowDataBound
),添加如下逻辑:
// 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");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.