|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
CustomWeb Controls and EventsI've got quite the unexpected problem occuring here and I can't see to figure this out. I've developed 2 custom controls that inherit from the WebControl class. This first control is basically a DHTML flyout menu that allows the user to make a selection. This control implements IPostBackEventHandler and within the overriden "AddAttributesToRender" method I have added "writer.AddAttribute(HtmlTextWriterAttribute.Onclick, Page.GetPostBackClientEvent(this,"")); so that my control can raise an event based on the postback. Now if I add this control to a standard asp.net page and wire my controls "ActionSelected" event to a method of the page it works just fine. However the goal is to have my second custom control (again, derives from WebControl) which is basically a HTMLTable use the first control. When I say use i mean I have defined a method with the correct signature and attach this method to the other controls "ActionSelected" event. This never seems to work. I don't understand why a page can use the control and listen for events but another control cannot receive the events. Besides recieving the event everything else works and displays correctly. Event the post back occurs - just no event being raised. Any help GREATLY appreciated! Does the second control create the first one in CreateChildControls or when?
And does it implement INamingContainer interface if it does? Show quoteHide quote "Michael Morse" <MichaelMo***@discussions.microsoft.com> wrote in message news:4FAE4840-6486-4CC0-969D-808BD974AEBB@microsoft.com... > Hi Everyone, > > I've got quite the unexpected problem occuring here and I can't see to > figure this out. > > I've developed 2 custom controls that inherit from the WebControl class. > > This first control is basically a DHTML flyout menu that allows the user > to > make a selection. This control implements IPostBackEventHandler and within > the overriden "AddAttributesToRender" method I have added > "writer.AddAttribute(HtmlTextWriterAttribute.Onclick, > Page.GetPostBackClientEvent(this,"")); so that my control can raise an > event > based on the postback. > > Now if I add this control to a standard asp.net page and wire my controls > "ActionSelected" event to a method of the page it works just fine. > > However the goal is to have my second custom control (again, derives from > WebControl) which is basically a HTMLTable use the first control. When I > say > use i mean I have defined a method with the correct signature and attach > this > method to the other controls "ActionSelected" event. > > This never seems to work. I don't understand why a page can use the > control > and listen for events but another control cannot receive the events. > > Besides recieving the event everything else works and displays correctly. > Event the post back occurs - just no event being raised. > > Any help GREATLY appreciated!
Need some advice on a GridView control.
Events for programatically added controls UserControl values lost on PostBack Menu control. Clickable area Custom Server Controls and javascript Exposing an event handler as a control property Clikable rows in Grid View I want to know what is a Functional Specification Document? filtering according to the Id of current row in a Gridview custom server control: problem with designer |
|||||||||||||||||||||||