Click here to Skip to main content
11,922,641 members (55,112 online)
Rate this:
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 20:25pm
PogoboyKramer 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 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 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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web04 | 2.8.151125.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