调用事件处理程序的另一种方法种方法、事件、程序

2023-09-04 11:40:57 作者:傻瓜╮你是我的唯一

我怎么还可以从隐藏页相同的code另一种方法,下面的方法?

How can I call the following method from another method on same code behind page?

protected void CustomValidatorDelLN_ServerValidate(object sender, ServerValidateEventArgs args)
    {
        bool is_valid = txtDeliveryLastName.Text != "";
        txtDeliveryLastName.BackColor = is_valid ? System.Drawing.Color.White : System.Drawing.Color.LightPink;
        args.IsValid = is_valid;
    }

我不知道如何处理(对象发件人,ServerValidateEventArgs参数)位。我称之为 CustomValidatorDelLN_ServerValidate(); 什么我把括号内

I don't know how to handle the (object sender, ServerValidateEventArgs args) bit. I call CustomValidatorDelLN_ServerValidate(); What do I put inside the brackets?

推荐答案

这样的事情可以工作...

Something Like this can work...

    protected void CustomValidatorDelLN_ServerValidate(object sender, ServerValidateEventArgs args)
    {

        args.IsValid = isValid();
    }


protected bool isValid()
{

    bool is_valid = txtDeliveryLastName.Text != "";
        txtDeliveryLastName.BackColor = is_valid ? System.Drawing.Color.White : System.Drawing.Color.LightPink;
    return is_valid;
}