Click here to Skip to main content
Rate this: bad
good
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" />
</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 27-Nov-10 20:25pm
Comments
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
good
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!
  Permalink  
Comments
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 OriginalGriff 365
1 Sergey Alexandrovich Kryukov 319
2 CPallini 275
3 DamithSL 214
4 Maciej Los 185
0 OriginalGriff 5,455
1 DamithSL 4,457
2 Maciej Los 3,885
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,115


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 28 Nov 2010
Copyright © CodeProject, 1999-2014
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