应该在事件处理程序中查询具有CausesValidation = True的控件

时间:2015-10-14 07:58:31

标签: c# asp.net

我收到以下错误

  

在验证发生之前无法调用Page.IsValid。它   应该在事件处理程序中查询具有的控件   CausesValidation = True并启动回发,或者在调用之后   Page.Validate。

这是我的代码:

public override void Validate(string grp)
    {// redioHospitalType this my radio button based on this type checking this.. 
        if (redioHospitalType.SelectedValue == "CH")
        {
// reqfieldNoofHospitals -this is my required field ID
            bool enableValidators = true;
            reqfieldNoofHospitals.Enabled = enableValidators;
            base.Validate();
        }
    }

  protected void btnSubmit_Click(object sender, EventArgs e)
    {
            Page.Validate("signup");// here signup is validation group name .
            if (Page.IsValid)
            {

            }
}

0 个答案:

没有答案