Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

asp.net

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%>">
like image 426
Serenity Avatar asked Nov 12 '10 06:11

Serenity


2 Answers

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 %>'>
like image 74
Zain Shaikh Avatar answered Sep 28 '22 21:09

Zain Shaikh


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.

like image 25
NotMe Avatar answered Sep 28 '22 19:09

NotMe