Postbacks and CommandEventArgs

J

John Bankhead

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);
}
 
B

Brock Allen

CommandEventArgs.Empty is inherited from EventArgs. So you're really passing
EventArgs.Empty.
 
J

John Bankhead

Well, duh. I was making bad assumptions. Thanks

Brock Allen said:
CommandEventArgs.Empty is inherited from EventArgs. So you're really passing
EventArgs.Empty.




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.Co
mmandEventArgs)' 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);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top