开发者

"The server tag is not well formed." What's wrong?

开发者 https://www.devze.com 2023-01-25 06:00 出处:网络
I get the following parser error message. How can I 开发者_运维知识库fix this problem? The server tag is not well formed.

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. 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

The runat="server" is only needed for databinding.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消