views:

18

answers:

2

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.

+1  A: 

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.

Noon Silk
Ha ha - I knew it would be simple - thanks Silky...what a tool I am.
Ricardo Deano
A: 

Use the validation group property:

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

Barry