473,394 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How to know which LinkButton clicked?

On a webform, I am dynamically creating a bunch of LinkButton's. The number of LinkButton's being created will depend on the data that's coming back

When a Linkbutton is clicked, and it doesn't have an onclick event defined, the page still goes through postback. But how do I know what caused the postback.

I would simply like to know the ID of the LinkButton that was clicked.

Your help is appreciated
Nov 18 '05 #1
8 3435
Sounds like you need to use the Command event and associate a unique command name to each linkbutton when you create it

http://msdn.microsoft.com/library/de...mmandtopic.asp
Nov 18 '05 #2
Thanks Dune, I'll check that out.
I was getting stumpted because Request.Form["__EVENTTARGET"] was returning ""
Nov 18 '05 #3
Sounds like you need to use the Command event and associate a unique command name to each linkbutton when you create it

http://msdn.microsoft.com/library/de...mmandtopic.asp
Nov 18 '05 #4
Thanks Dune, I'll check that out.
I was getting stumpted because Request.Form["__EVENTTARGET"] was returning ""
Nov 18 '05 #5
In the example in the MSDN article, the LinkButtons are pre-defined in the webform. In my code, I'm adding the Controls directly to the page in the codebehind
Thus, I'm not able to define the OnCommand property of the LinkButton in the codebehind when I create the LinkButton control.

In concept, this is a great idea, because I would set the OnCommand property of every LinkButton control on the page to the same event.
Nov 18 '05 #6
In the example in the MSDN article, the LinkButtons are pre-defined in the webform. In my code, I'm adding the Controls directly to the page in the codebehind
Thus, I'm not able to define the OnCommand property of the LinkButton in the codebehind when I create the LinkButton control.

In concept, this is a great idea, because I would set the OnCommand property of every LinkButton control on the page to the same event.
Nov 18 '05 #7
Figured it out, when creating the LinkButton in code

oLinkButton.Command += new CommandEventHandler(this.lnkButton_Click)

and then I define my even

private void lnkButton_Click(Object sender, CommandEventArgs e
{Response.Write(e.CommandName.ToString());}
Nov 18 '05 #8
Figured it out, when creating the LinkButton in code

oLinkButton.Command += new CommandEventHandler(this.lnkButton_Click)

and then I define my even

private void lnkButton_Click(Object sender, CommandEventArgs e
{Response.Write(e.CommandName.ToString());}
Nov 18 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: George | last post by:
On a webform, I am dynamically creating a bunch of LinkButton's. The number of LinkButton's being created will depend on the data that's coming back When a Linkbutton is clicked, and it doesn't...
10
by: Bharat | last post by:
Hi Folks, Suppose I have two link button on a page (say lnkBtn1 and lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically created control. And On the click event of the lnkBtn2 I...
3
by: rn5a | last post by:
Consider the following code which creates LinkButtons dynamically: For i = 1 to 5 lnkBut = New LinkButton lnkBut.ID = "lnkBut" & i lnkBut.Text = i.ToString & " " lnkBut.CommandName = i...
7
by: PGPS | last post by:
Hi, I want to know who all clicked a particular link (cgi-script) on any website. 1. Link points to my own webserver 2. Link can be sent anyway. Either emailed or posted on a site which needs...
5
by: Peter Larsen [CPH] | last post by:
Hi, The following sample shows a LinkButton in the HeaderTemplate of a Repeater control. The problem is that i'm not able to access the linkbutton in code (in the cs file) as long as the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.