Groups | Blog | Home
all groups > asp.net building controls > march 2005 >

asp.net building controls : Postbacks and CommandEventArgs



John Bankhead
3/31/2005 8:03:03 AM
In the situation below I am calling "OnCommand(CommandEventArgs.Empty);" from
IPostBackEventHandler.RaisePostBackEvent. but I get the compile errors:

The best overloaded method match for
'DSTControls.PortfolioDashboard.OnCommand(System.Web.UI.WebControls.CommandEventArgs)' has some invalid arguments

-and -

Argument '1': cannot convert from 'System.EventArgs' to
'System.Web.UI.WebControls.CommandEventArgs'

Why? The param in OnCommand is clearly of type CommandEventArg. Also, if I
change the type in RaisePostBackEvent to EventArgs, then the same compile
error occurs in reverse.


public virtual void OnCommand(CommandEventArgs e){
CommandEventHandler handler = (CommandEventHandler)Events[Command];
if (handler != null)
handler(this,e);
// The Command event is bubbled up the control hierarchy.
RaiseBubbleEvent(this, e);
}

private void lb_Command(object sender, CommandEventArgs e){
OnCommand(e);
}

void IPostBackEventHandler.RaisePostBackEvent(string eventArgument){
OnCommand(CommandEventArgs.Empty);
}

--
Brock Allen
3/31/2005 8:07:34 AM
CommandEventArgs.Empty is inherited from EventArgs. So you're really passing
EventArgs.Empty.

-Brock
DevelopMentor
http://staff.develop.com/ballen



[quoted text, click to view]


John Bankhead
3/31/2005 8:23:01 AM
Well, duh. I was making bad assumptions. Thanks

[quoted text, click to view]
AddThis Social Bookmark Button