Shrv11
Shrv11

Reputation: 17

Disable Required validation for a specific button & textbox

I want to disable required validator field for a specific button click which is not check only a textbox. i've tried this code in the button click but not worked. so need this type of code how solve.

protected void Button3_Click(object sender, EventArgs e)
{
     if (TextBox1 == null)
    {
        RequiredFieldValidator1.EnableViewState = false;
    }
}

Upvotes: 1

Views: 2581

Answers (2)

Aginjith GJ
Aginjith GJ

Reputation: 73

RequiredFieldValidator61.Visible = false; is what worked for me. It disables the error massage.

Upvotes: 0

Hardik Mer
Hardik Mer

Reputation: 836

Just set CausesValidation="false" on your button property.

If you wish to validate that particular button with some other TextBox or control you can set ValidationGroup="groupA" to those controls and name it same group.

Upvotes: 1

Related Questions