Bypassing FieldValidator

Bypassing FieldValidator

Post by Stuart Sha » Fri, 06 Sep 2002 15:29:55



Hello All

I am just getting started with ASP.Net. I have created a form that is
dynamic so when a
user selects a certain value within the form it changes the Form Inputs. The
Problem I have
encouted is that when I select the button to change the form to make the
changes in the form I must
1st validate the fields before proceeding.

In the sample code below how do I make id="Button2 so I can change the form
with out going thru the
validation process.

Thanks
Stuart

<form Runat="Server">
<html>
<body>

<asp:TextBox id="txtFirstName" Runat="Server" Columns="30"></asp:TextBox>
<asp:RequiredFieldValidator id="RequiredFieldValidator1"
ErrorMessage="Please Enter the First Name" ControltoValidate="txtFirstName"
runat="Server"></asp:RequiredFieldValidator>

<asp:TextBox id="txtLastName" Runat="Server" Columns="30"></asp:TextBox>
<asp:RequiredFieldValidator id="RequiredFieldValidator2"
ErrorMessage="Please Enter the Last Name" ControltoValidate="txtLastName"
runat="Server"></asp:RequiredFieldValidator>

<asp:Button id="Button1" onclick="Button_Click" Runat="Server"
Text="Submit"></asp:Button>
<asp:Button id="Button2" onclick="Button_ChangeForm" Runat="Server"
Text="Select Dept"></asp:Button>

</form>
</body>
</html>

 
 
 

Bypassing FieldValidator

Post by Stev » Fri, 06 Sep 2002 18:48:25


Hi Stuart!

You simply need to add the CausesValidation="False" attribute to the button.
So the code for the select button would be:
<asp:Button id="Button2" CausesValidation="False"
onclick="Button_ChangeForm" Runat="Server"
        Text="Select Dept"></asp:Button>

Cheers

Steve


Quote:> Hello All

> I am just getting started with ASP.Net. I have created a form that is
> dynamic so when a
> user selects a certain value within the form it changes the Form Inputs.
The
> Problem I have
> encouted is that when I select the button to change the form to make the
> changes in the form I must
> 1st validate the fields before proceeding.

> In the sample code below how do I make id="Button2 so I can change the
form
> with out going thru the
> validation process.

> Thanks
> Stuart

> <form Runat="Server">
> <html>
> <body>

> <asp:TextBox id="txtFirstName" Runat="Server" Columns="30"></asp:TextBox>
> <asp:RequiredFieldValidator id="RequiredFieldValidator1"
> ErrorMessage="Please Enter the First Name"

ControltoValidate="txtFirstName"

- Show quoted text -

Quote:> runat="Server"></asp:RequiredFieldValidator>

> <asp:TextBox id="txtLastName" Runat="Server" Columns="30"></asp:TextBox>
> <asp:RequiredFieldValidator id="RequiredFieldValidator2"
> ErrorMessage="Please Enter the Last Name" ControltoValidate="txtLastName"
> runat="Server"></asp:RequiredFieldValidator>

> <asp:Button id="Button1" onclick="Button_Click" Runat="Server"
> Text="Submit"></asp:Button>
> <asp:Button id="Button2" onclick="Button_ChangeForm" Runat="Server"
> Text="Select Dept"></asp:Button>

> </form>
> </body>
> </html>


 
 
 

Bypassing FieldValidator

Post by Stuart Sha » Sat, 07 Sep 2002 15:33:20


Thanks !!!
Steve


> Hi Stuart!

> You simply need to add the CausesValidation="False" attribute to the
button.
> So the code for the select button would be:
> <asp:Button id="Button2" CausesValidation="False"
> onclick="Button_ChangeForm" Runat="Server"
>         Text="Select Dept"></asp:Button>

> Cheers

> Steve



> > Hello All

> > I am just getting started with ASP.Net. I have created a form that is
> > dynamic so when a
> > user selects a certain value within the form it changes the Form Inputs.
> The
> > Problem I have
> > encouted is that when I select the button to change the form to make the
> > changes in the form I must
> > 1st validate the fields before proceeding.

> > In the sample code below how do I make id="Button2 so I can change the
> form
> > with out going thru the
> > validation process.

> > Thanks
> > Stuart

> > <form Runat="Server">
> > <html>
> > <body>

> > <asp:TextBox id="txtFirstName" Runat="Server"

Columns="30"></asp:TextBox>
Quote:> > <asp:RequiredFieldValidator id="RequiredFieldValidator1"
> > ErrorMessage="Please Enter the First Name"
> ControltoValidate="txtFirstName"
> > runat="Server"></asp:RequiredFieldValidator>

> > <asp:TextBox id="txtLastName" Runat="Server" Columns="30"></asp:TextBox>
> > <asp:RequiredFieldValidator id="RequiredFieldValidator2"
> > ErrorMessage="Please Enter the Last Name"

ControltoValidate="txtLastName"

- Show quoted text -

Quote:> > runat="Server"></asp:RequiredFieldValidator>

> > <asp:Button id="Button1" onclick="Button_Click" Runat="Server"
> > Text="Submit"></asp:Button>
> > <asp:Button id="Button2" onclick="Button_ChangeForm" Runat="Server"
> > Text="Select Dept"></asp:Button>

> > </form>
> > </body>
> > </html>

 
 
 

1. FieldValidator Javascript

I am using visual Studio to create a form with a required field validator.
The properties for the validator are enableClientScript=false, but I still
find the following line of code in my browser.

<input language="javascript" onclick="if (typeof(Page_ClientValidate) ==
'function') Page_ClientValidate(); "

which is pretty useles since there is no external Scriptcode or anything
else. My customer doesen't like to see this line in the project since it is
supposed to be clientside script free.

Is there a way to tell ASP.NET not to generate clientside script, especially
when it is not neccessary.

Thank you

Karl

2. Announce - Typo Circle event, Edinburgh Scotland

3. FieldValidator causing WebForm Events not to function

4. New Icons from Performance Beta

5. FieldValidator

6. Blank cdr's

7. Asynchronous event notifications bypass custom channels sinks

8. It is here...see you beta tester online shortly

9. Global error handler is bypassed by keyboard accelerator

10. Bypass an "OK" button during automated program start...

11. cuddle exposures hare bypasses 51ec5d426e8c Havilland shaming microeconomics crumbles

12. by-pass internal funcs while step through debugging

13. WCF: Bypassing maximum UDP datagram size