Event Handling in Server Controls

  • Thread starter Thread starter Iyigun Cevik
  • Start date Start date
I

Iyigun Cevik

I have a server control which contains several LinkButtons like
MyLink = new LinkButton();
MyLink.Text = "Cikar";
MyLink.Click += new EventHandler(this.MyLinkClicked);
Controls.Add( CikarLink );

When i press on link button in webpage, MyLinkClicked function never starts.
I think somebody else handles event but not my server control. I see
something in MSDN like UniqueID, but i couldn't figure out how to make it.
What should i do in order to handle Click event of my LinkButton's in my
server control?
Iyigun Cevik
 
Where in your control you wire these events? Does this control implement
INamingContainer interface (is it non-user control)?
 
Yes, it implements INamingContainer.
I have this function in my control class :

private void MyLinkClicked(Object sender, EventArgs e)

and before adding LinkButton to my server control's Controls collection i do
:

MyLink.Click += new EventHandler(this.MyLinkClicked);

but it doesn't work. I mean when i click on button MyLinkClicked function
doesn't run.
Iyigun Cevik
 
Back
Top