Click here to Skip to main content
15,914,163 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

Try this code:

UI:
XML
<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:

C#
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;
  }
 
Share this answer
 
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900