Click here to Skip to main content
11,796,275 members (77,594 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# ASP.NET User-controls Web , +
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 19: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 460
1 Abhinav S 368
2 OriginalGriff 340
3 CPallini 269
4 Sergey Alexandrovich Kryukov 252
0 OriginalGriff 2,012
1 Maciej Los 1,615
2 KrunalRohit 1,310
3 CPallini 1,015
4 Richard MacCutchan 828

Advertise | Privacy | Mobile
Web02 | 2.8.151002.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