|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Exposing an event handler as a control propertyI have a custom server control that can contain one or more buttons. I'm trying to expose an event handler as a property so that the buttons can fire a click event when clicked. However, I'm getting the following error: Cannot create an object of type 'System.EventHandler' from its string representation 'OnSubmit' for the 'OnSubmit' property. My control's tag looks like this: <stuff:MyControl OnSubmit="OnSubmit" Width="430" runat="server">...</stuff:MyControl> The property looks like this: public EventHandler OnSubmit { get { return _onSubmit; } set { _onSubmit = value; } } I've tried the property with and without a type converter without success. Any help would be much appreciated. Thanks, Paul I'm not sure what you are trying to accomplish with this approach. You
probably only need a setter function which would simply fire the onSubmit event not assign it to an event variable since that doesn't accomplish much. I don't see a reason for a getter either. What are you getting? A fired event? In that case the correct event handler is already invoked. -- Show quoteHide quote________________________ Warm regards, Alvin Bruney [MVP ASP.NET] [Shameless Author plug] Professional VSTO.NET - Wrox/Wiley The O.W.C. Black Book with .NET www.lulu.com/owc, Amazon Blog: http://www.msmvps.com/blogs/alvin ------------------------------------------------------- <paul.hes***@gmail.com> wrote in message news:1156742868.804718.265710@i3g2000cwc.googlegroups.com... > Hi all, > > I have a custom server control that can contain one or more buttons. > I'm trying to expose an event handler as a property so that the buttons > can fire a click event when clicked. However, I'm getting the following > error: > > Cannot create an object of type 'System.EventHandler' from its string > representation 'OnSubmit' for the 'OnSubmit' property. > > My control's tag looks like this: > > <stuff:MyControl OnSubmit="OnSubmit" Width="430" > runat="server">...</stuff:MyControl> > > The property looks like this: > > public EventHandler OnSubmit > { > get { return _onSubmit; } > set { _onSubmit = value; } > } > > I've tried the property with and without a type converter without > success. > > Any help would be much appreciated. > > Thanks, > > Paul >
objectdataSource case sensitive with parameters??
Don't understand state in WebControls class Page CallBack Add control to TreeView (ASP.NET 2.0) Using Gridview To Export Data To Excel Error (ASP.NET 2.0) Master Page Where in the page lifecycle does validation occur? DetailsView EditItemTemplate CheckBoxList2 bound and Related to CheckBoxList1 Treeview/Treenode oncheck clientside event handler dynamically set property on a control |
|||||||||||||||||||||||