Bind <a> href to Code Behind property
asp.net, code-behind, data-binding, hyperlink, properties
Solution
If that is all you want to do to those `<a>` tags, you don't need to make them server-side controls. Get rid of the `runat="server"` and it should work.
Problem
I want to set a public property in my code behind file, and then use that property to set the href property of several HtmlGenericControl `<a>` tags. Here is what I've tried: Code behind: ``` public partial class className: System.Web.UI.MasterPage { private string _linkValue = ""; public string linkValue { get { return _linkValue; } } protected void Page_Load (object sender, EventArgs e) { SetLink(); } private void SetLink() { _linkValue = "myUrl"; } } ``` .aspx file ``` <ul> <li><a runat="server" href="<%= linkValue %>">Link 1</a></li> <li><a runat="server" href="<%= linkValue %>">Link 2</a></li> <li><a runat="server" href="<%= linkValue %>">Link 3</a></li> </ul> ``` Instead of the href being set to "myUrl", the href is `%3C%25=%20linkValue%25%3E1`