Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C# ASP.NET Web-Development , +
Hi friends,
The following code is my ASP.NET page :
<MdsMenu:MenuItem Text="Button" Href="#">
<asp:Button ID="Button1" runat="server" Text="Button 01" OnClick="Button_Click" />
<asp:Button ID="Button2" runat="server" Text="Button 02" OnClick="Button_Click" />
I don't know why Button_Click event doesn't fire !!!
protected void Button_Click(object sender, EventArgs e)
Button senderButton = sender as Button;
Label1.Text =  senderButton.ID.ToString();
MdsMenu:MenuItem is my custom WebControl.
If I insert a Button control out of MdsMenu:MenuItem tag it works well but if I inserted it within MdsMenu:MenuItem tag it doesn't fire the concerned method.
What's wrong with my code ?
Posted 27-Nov-10 20:25pm
PogoboyKramer at 28-Nov-10 2:04am
I think you have answered your own question. What is an "MdsMenu:MenuIem" and does it perhaps as a user control gobble up the button click event. If that is the case, you'll have to figure out how to handle the click yourself.
Mohammad Dayyan at 28-Nov-10 2:09am
So, could you guide me how I can handle the controls' events that are within my WebControl tags ?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Did you implemented INamingContainer interface in your MdsMenu:MenuItem custom control?
If you are building a composite web control you need to do that!
Mohammad Dayyan at 29-Nov-10 11:40am
the MdsMenu:MenuItem inherits from INamingContainer . How can I implement it? Could you please post a useful link? Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 495
1 Sergey Alexandrovich Kryukov 429
2 OriginalGriff 360
3 CHill60 280
4 Sascha Lefévre 269
0 Sergey Alexandrovich Kryukov 10,017
1 OriginalGriff 9,495
2 Peter Leow 5,241
3 Kornfeld Eliyahu Peter 3,373
4 Maciej Los 3,076

Advertise | Privacy | Mobile
Web04 | 2.8.150327.1 | Last Updated 28 Nov 2010
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100