-1

In asp.net Depending on Experience I should validate the salary of an employee.

If the employee is fresher his salary should be 1 lac to 1.5 lac. Or salary = 1.5 lac * years of exp to 3.5 * years of exp.

** i have tried his**** protected void Button1_Click(object sender, EventArgs e) {

    if (IntExp == 0)
    {
        RangeValidator1.MaximumValue = "150000";
        RangeValidator1.MinimumValue = "100000";

        RangeValidator1.Type = ValidationDataType.Integer;
        RangeValidator1.Validate();
        if (!RangeValidator1.IsValid)
        {
            RangeValidator1.ErrorMessage = "Enter CTC between 100000 and 150000";
        }
        Response.Redirect("ABCAddEmp.aspx");

    }
    else
    {
        int max = IntExp * 150000;
        int min = IntExp * 350000;
        RangeValidator1.MaximumValue = "max";
        RangeValidator1.MinimumValue = "min";
        RangeValidator1.Type = ValidationDataType.Integer;
        RangeValidator1.Validate();

        if (!RangeValidator1.IsValid)
        {
            RangeValidator1.ErrorMessage = "Enter CTC between " + max + " and " + min;
        }
        Response.Redirect("ABCAddEmp.aspx");
    }
4

1 回答 1

3

您正在寻求实现自定义验证器。当您将自定义验证器放在页面上时,您的 controlToValidate 将是薪水。然后你需要定义你的 ServerValidate 事件。在这种情况下,您可以根据是新员工还是有经验来验证员工的输入。祝你好运。

于 2012-10-07T09:58:24.037 回答