Question

Afternoon all.

Here's an easy one for you that I can't figure out.

I have a requiredfield validator that is doing its job too well! Upon the lnkLogOut, the user should be logged out but the requiredfield validator is preventing this.

protected void lnkLogOut_Click(object sender, EventArgs e)
        {
            Session.Abandon();
            Response.Write("<script language='javascript'> { window.close();}</script>");
        }

How do I go about essentially voiding the required field validator in this instance i.e. the user may go into the page, realise this is not the way forward, does not touch the controls (so they are still empty) but the required validator is ignored.

Apologies for the thick question.

Was it helpful?

Solution

You may set CausesValidation to False on that control, like so:

<asp:Link runat="server" ID="lnkLogout" CausesValidation="False" ... />

You may also like to review ValidationGroups, to indicate the certain controls should only validate certain groups of input fields, etc.

OTHER TIPS

Use the validation group property:

http://msdn.microsoft.com/en-us/library/ms227424.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top