haysam haysam - 8 months ago 38
ASP.NET (C#) Question

enabling/disabling <a> tag through c# code

I am trying to enable/disable a "a" tag that's in my html code through my C# back code. I know if it was a button then I would just use, xxx.Visible="false/true" but i guess "a" tag does not have any features for backend code. Here is what I have,


if (Session["SessionUsersLoginId"] == null)

alreadyMemberLabel.Visible = true;
SignInButton.Visible = true;
forgotdButton.Visible = true;
passwordLabel.Visible = true;
passwordTextBox.Visible = true;
Right here should disable visibility for "login_pop" a tags


<span style="width:32%; float:right;">
<div class="panel">
<a href="#login_form" id="login_pop">Log In</a>
<a href= "AddUsers.aspx" id="login_pop">Sign Up</a>
<span style="width:32%; float:right;">
<asp:Button ID="forgotdButton" CssClass="btn-link forgotPass" runat="server" Height="25px" Text="Forgot Password?"
onclick="forgotdButton_Click" Width="135px" />



Maybe there is a way to enable/disable through id?
Thanks you


Firstly, you have two same IDs on different elements (login_pop) they should be unique.

Second, you can make the <a> tag a server component and that way you can access it from your code-behind:


<a href="#login_form" id="login_pop" runat="server">Log In</a>


login_pop.Disabled = true;