Vijay
Vijay

Reputation: 81

Click event of Asp Link Button

I have 4 Link buttons in asp.net. I have added same key handler function to all those buttons(using add handler). Now i have to read that which button is clicked. but i can not check their text property as the text is changing dynamically too. How can i read which button is clicked.

Any different approach is also welcome.

Upvotes: 0

Views: 167

Answers (2)

Anant Dabhi
Anant Dabhi

Reputation: 11104

You have to assign any one unique value to differentiate Link-button you also can use different link-button Command Argument or ID for different link-button

and use like

void LinkButton_Click(Object sender, EventArgs e) 
      {
       var senderss = (LinkButton)sender;
       var uniqueid = senderss.ID.ToString();
       var CommandArgs= senderss.CommandArgument.ToString();
      }

Upvotes: 1

Aghilas Yakoub
Aghilas Yakoub

Reputation: 28970

You can try with this code - based on sender argument

void LinkButton_Click(Object sender, EventArgs e) 
{
      var control =(LinkButton) sender;
      var id = control.Id;
      System.Console.Write(id);

}

Upvotes: 0

Related Questions