简体   繁体   English

“服务器标签形成不好。”怎么了?

[英]“The server tag is not well formed.” What's wrong?

I get the following parser error message. 我收到以下解析器错误消息。 How can I fix this problem? 我该如何解决这个问题?

The server tag is not well formed. 服务器标签格式不正确。

Code: 码:

<a href="#" class="mySprite id<%# ((int)DataBinder.Eval(Container,"ItemIndex")) % 6 + 1%>">

First of all, your anchor is client side, you should add an attribute of runat="server" to this. 首先,你的锚是客户端,你应该为此添加runat="server"的属性。 Second, try using it like following. 其次,尝试使用它如下。

<a href="#" runat="server" id="mySprite1" 
class='<%# "mySprite id" + ((int)DataBinder.Eval(Container,"ItemIndex")) % 6 + 1 %>'>

It might be helpful to review the difference in expressions: http://blogs.msdn.com/b/dancre/archive/2007/02/13/the-difference-between-lt-and-lt-in-asp-net.aspx 查看表达式的差异可能会有所帮助: http//blogs.msdn.com/b/dancre/archive/2007/02/13/the-difference-between-lt-and-lt-in-asp-net的.aspx

The runat="server" is only needed for databinding. 只有数据绑定才需要runat="server"

So, use the <%= %> syntax instead. 因此,请改用<%= %>语法。 Also make sure your quotes aren't getting mixed up, so use ' for the outer one and " for the inner ones. 还要确保你的报价不会混淆,所以使用'为外部的""为内部的“。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM