tags:

views:

39

answers:

1

Hi,

I want to raise the:

private void txtbox_startdate_Validating(object sender, System.ComponentModel.CancelEventArgs e)
    {}

Function from a key leave event. The leave event looks like:

private void txtbox_startdate_Leave(object sender, EventArgs e)
    {}

The trouble is of course if I try and call it in this manner:

txtbox_startdate_Validating(sender, e)

An error is raised because in this case 'e' is an EventArgs whereas the validation function wants a System.ComponentModel.CancelEventArgs and so, how do I convert EventArgs to a System.ComponentModel.CancelEventArgs or create one so that I can call my validation function?

Thanks, R.

A: 

normally whatever the validator is, you can just call Validate() on it instead of doing this.

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.basevalidator.validate.aspx

Otherwise, just 'new' the canceleventargs yourself - it's not special, the constructors are public.

http://msdn.microsoft.com/en-us/library/system.componentmodel.canceleventargs.canceleventargs.aspx

James Manning