How conditional redirection using <a> tag in HTML depending on QueryString value in asp.net?

I am redirecting to the Teammember.aspx page with javascript from the code behind.

teammember.Attributes.Add("onclick", "window.location.href='TeamMemberDetails.aspx?Id=" + Id + "'" + "&isabout=true");

When advancing on the TeamMemberDetails.aspx page, I have an anchor tag:

 <a style="border: 0px none; float: left;" href="TeamMember.aspx">
    <img alt="<--" src="Images/ArrowLeft.png" style="display: inline-block; cursor: pointer;border: 0 none;" />
 </a>

Now, depending on the Querystring ie isabout parameter, the page should be redirected. if isabout = true, then it should redirect to the Listlist.aspx else other.aspx page using the HTML anchor tag (conditional redirection)

0
source share
1 answer

put the attribute runat="server"and find the anchor tag in the code behind.

  <a id="lnktoRedirect" runat="server">Redirect</a>

Code behind:

 if (isabout)
 {
       lnktoRedirect.HRef = "Memberlist.aspx";
 }
 else
 {
       lnktoRedirect.HRef = "other.aspx";
 }
+1
source

All Articles