Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Dynamic creation of linkButton control in Code behind VISIT Postback

0 views
Skip to first unread message

pie...@videotron.ca

unread,
Jan 28, 2002, 8:14:05 PM1/28/02
to
Hello.

I have a PlaceHolder object on a Form. I create several new:

System.Web.UI.WebControls.LinkButton linkButton = new LinkButton();
linkButton.ID = "LinkButton1" ;
linkButton.Text = sBuffer + "<br>";
this.PlaceHolder1.Controls.Add (linkButton);

in the code behind.

------------------------------------------------------------------------------------------------------------------

I use the same .ID for all link buttons since I want a single point of entry
back.

ASP.net then generates the following code

href="javascript:__doPostBack('LinkButton1','')">Technical<br></a><a
id="LinkButton1" href="javascript:__doPostBack('LinkButton1','')
href="javascript:__doPostBack('LinkButton1','')">Non Technical<br></a><a
id="LinkButton1" href="javascript:__doPostBack('LinkButton1','')

In the LinkButton event handler

private void LinkButton1_Click(object sender, System.EventArgs e)
{
//Is there a way for me to find out which link button called?
}

Comments welcomed. Thanks.

Naveen K Kohli[444173]

unread,
Jan 28, 2002, 5:23:05 PM1/28/02
to
The event argument "sender" corresponds to the control that fired the event.
Check if its of type LinkButton and then check the text (label) associated
with it. thats probably the only way you can idetify if the IDs are same.

Naveen
<pie...@videotron.ca> wrote in message
news:R2k58.18168$4v.9...@weber.videotron.net...

0 new messages