Reputation: 6918
I want to pass query string in anchor tag but facing some error i.e "server tag is not well formed". My code is:-
<a href="EditUser.aspx?uid='<%# Eval("Userid") %>'" id="aa" runat="server" />
Upvotes: 0
Views: 13933
Reputation: 103348
You cannot use code breaks with string text together for an attribute value for an element which is ran server side. Instead you can use String.Format()
to form the same response, using single quotes.
<a href='<%# String.Format("EditUser.aspx?uid={0}", Eval("Userid")) %>' id="aa" runat="server" />
Upvotes: 0
Reputation: 5806
I generally use:
<a href='<%# Eval("Userid","EditUser.aspx?uid={0}") %>'>Text</a>
/pre>
If you remove runat="server"
and single quotes before and after eval expression, your code will also start working
Happy coding
Upvotes: 1
Reputation: 10872
Try this
<a href='<%# "EditUser.aspx?uid=" + Eval("Userid") %>' id="aa" runat="server" />
Upvotes: 0