Click here to Skip to main content
14,391,646 members
Rate this:
Please Sign up or sign in to vote.
Hi,

I have 4 link buttons in my aspx page.

if one linkbutton has clicked then i put as enable false and set gray color to my linkbutton text

up to this working fine

but my problem is that if i click another linkbutton then my first linkbutton have to change enable true and text color has to change.but my first linkbutton is disappeared.


how to set only one linkbutton enable false and other linkbuttons are visible true

please help me
Posted
Comments
Anuj Banka 6-Dec-11 5:00am
   
Show us your code

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Try this code:

UI:
<asp:LinkButton ID="LinkButton1" runat="server" Font-Bold="True"

       Font-Underline="False" onclick="LinkButton1_Click">one</asp:LinkButton><br />
   <asp:LinkButton ID="LinkButton2" runat="server" Font-Bold="True"

       Font-Underline="False" onclick="LinkButton2_Click">two</asp:LinkButton><br />
   <asp:LinkButton ID="LinkButton3" runat="server" Font-Bold="True"

       Font-Underline="False" onclick="LinkButton3_Click">three</asp:LinkButton><br />
   <asp:LinkButton ID="LinkButton4" runat="server" Font-Bold="True"

       Font-Underline="False" onclick="LinkButton4_Click">four</asp:LinkButton><br />



C# code:

protected void LinkButton1_Click(object sender, EventArgs e)
  {
      LinkButton1.Enabled = false;
      LinkButton2.Enabled = true;
      LinkButton3.Enabled = true;
      LinkButton4.Enabled = true;
      LinkButton1.BackColor = System.Drawing.Color.Gray;
  }
  protected void LinkButton2_Click(object sender, EventArgs e)
  {
      LinkButton2.Enabled = false;
      LinkButton1.Enabled = true;
      LinkButton3.Enabled = true;
      LinkButton4.Enabled = true;
      LinkButton2.BackColor = System.Drawing.Color.Gray;
  }
  protected void LinkButton3_Click(object sender, EventArgs e)
  {
      LinkButton3.Enabled = false;
      LinkButton1.Enabled = true;
      LinkButton2.Enabled = true;
      LinkButton4.Enabled = true;
      LinkButton3.BackColor = System.Drawing.Color.Gray;
  }
  protected void LinkButton4_Click(object sender, EventArgs e)
  {
      LinkButton4.Enabled = false;
      LinkButton1.Enabled = true;
      LinkButton3.Enabled = true;
      LinkButton2.Enabled = true;
      LinkButton1.BackColor = System.Drawing.Color.Gray;
  }
   
Comments
[no name] 6-Dec-11 6:36am
   
5! this should be the answer, i dont know why OP didnt try this

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100