this runat="server" html element:
<a runat="server" href='<%#link%>' id="thelink"> test </a> and need print inside href value of link variable (defined on .cs):
protected string link = "http://www.test.com"; but i'm not able: variable value "empty". wrong?
the same if use native hyperlink control...
i think may change this
<a runat="server" href='<%#link%>' id="thelink"> test </a>
to this
<a href='<%=link%>' id="thelink"> test </a>
<%# runs code, doesn't output anything. <%= output whatever inside tags.
don't forget remove runat=server since <%= generate plain text if don't remove it.
or maybe can change this
<asp:linkbutton id="myid" runat="server" onclick="redirecttolink" text="test" /> behind code:
protected string link = "http://www.test.com"; protected void redirecttolink(object sender, eventargs e) { response.redirect(link); } or if insist use href code behind, can this:
<asp:label id="testlabel" runat="server" /> code behind:
protected string link = "http://www.test.com"; protected void page_load(object sender, eventargs e) { if (!ispostback) { testlabel.text = string.format("you have click on <a href=\"{0}\"> link </a>",link); } }
Comments
Post a Comment