i use this code in asp.net:
string link = "<a href=\"" + Request.Url.AbsolutePath + "?Id=" + x + ">" + "link" + "</a>";
literalLink.Text = link;
<asp:Literal ID="literalLink" runat="server"></asp:Literal>
but i have postback in this link.
i use this code in asp.net:
string link = "<a href=\"" + Request.Url.AbsolutePath + "?Id=" + x + ">" + "link" + "</a>";
literalLink.Text = link;
<asp:Literal ID="literalLink" runat="server"></asp:Literal>
but i have postback in this link.
If I understand correctly (and I may not), you just want to display the link after a PostBack. If that's the case, you can do it like this:
ASPX Code:
<asp:HyperLink ID="visitAgain" Text="Link" Visible="False" runat="server" />
Code Behind:
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
visitAgain.Visible = true;
visitAgain.NavigateUrl = Request.Url.AbsolutePath + "?Id" + x;
}
}
Doing it like this instead of having all the logic in the .aspx file has the added bonus of improved readability and cleaner code.
If you want a PostBack event to the page you're working on using a link, use the <asp:LinkButton>
element. It is the same as an ordinary button except that it displays as a common link.
<asp:LinkButton runat="server" Id="lnkButton" Text="I do a postback, yay" OnClick="TheFunctionThatHandlesTheClickIfNecessary" />