Click here to Skip to main content
15,121,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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" />
</MdsMenu:MenuItem>


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 ?
Thanks
Posted
Comments
fjdiewornncalwe 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

Did you implemented INamingContainer interface in your MdsMenu:MenuItem custom control?
If you are building a composite web control you need to do that!
   
Comments
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)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900