TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Chandan Kumar Sahoo
NA
83
6.8k
How to call method that handles the Click event for several
Sep 30 2015 5:03 AM
How to call method that handles the Click event for several buttons ?
Reply
Answers (
2
)
0
Bhushan Bhasme
0
812
274.6k
Sep 30 2015 5:26 AM
Hi Chandan,
YOu need To Use EventHandler..
Like
Button b1=new Button();
b1.Text = "Click here to activate";
b1.Location = new Point(20,55);
b1.Size = new Size(150,20);
b1.Click+= new EventHandler(GetData);
btnsample is id of any button andGetData is method which will get call on button click
=====
public void
GetData
(object sender,EventArgs e) {
//Here You will Get Data Of Button (i.e:properties Of Button)
}
Accepted Answer
0
Rashmiranjan Dalabehera
1.1k
663
1.7k
Sep 30 2015 5:29 AM
Hi Chandan,
Please clear me what exactly you want?
Try this code,if it will help you please accept me.
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="handleButtonClick" />
<asp:Button ID="Button2" runat="server" Text="Button" OnClick="handleButtonClick" />
<asp:Button ID="Button3" runat="server" Text="Button" OnClick="handleButtonClick" />
protected void handleButtonClick(object sender, EventArgs e)
{
Button btn = (Button)sender;
if (btn.ID=="Button2")
{
Response.Write("<b><i>You have clicked: " + btn.ID+"</i></b>");
}
if (btn.ID == "Button1")
{
Response.Write("<b><i>You have clicked: " + btn.ID + "</i></b>");
}
if (btn.ID == "Button3")
{
Response.Write("<b><i>You have clicked: " + btn.ID + "</i></b>");
}
}
Problem in multplying two columns in gridview in aspnet
checkbox gridview insert mysql