form double validation- server side and client side

Hi!

I would like to make a server side validation after calling a js function that makes the client-side validation.

I do not understand couple of things:

1. Do i need a server side button or  a simple HTML submit button in order to call both of the tests?

2. How do i call a server side function which is written in csharp  after i finish my JS validation (the submit  button is calling the JS function for validation first.)- is it possible to call it directly from a js function?

3. I know that my toolbox on asp.net  contains validation controls who probably are being used for the server side- How do i use them wisely to save me time -instead of writing another function in csharp (if the browser doesn't allow js) 

I have asp.net reguler version and not asp.net MVC

Thanx.

If anyone have any example that he did to validate a form - double validation

It will be terrific

 

Thanx!


click! click!
0
webcrab
2/17/2009 5:41:01 PM
asp.net.getting-started 91979 articles. 3 followers. Follow

3 Replies
1022 Views

Similar Articles

[PageSpeed] 38

1. You need a Server Side button. A simple HTML button control does not trigger events in the ASP.NET runtime (unless there is a runat="server" attribute). The HTML button will simple be served as is by IIS.

2. JavaScript operates on the client i.e. the web browser. So, it cannot call server side code. In C# all functions are called with parenthesis with any parametsr passed in otherwise, if no parameters are passed in, you still need the paranthesis (unlike VB.NET). For example. SomeCode();

3. Here's an example:

 

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

<asp:Button ID="Button1" runat="server" Text="Button" />

<asp:RequiredFieldValidator ID="RequiredFieldValidator1"

runat="server"

ControlToValidate="TextBox1"

EnableClientScript="False"

ErrorMessage="Required">

</asp:RequiredFieldValidator>

 

Please note: Some people disable JavaScript on their browser. Hence , the EnableClientScript="false" means the validation will occur on the server instead of the client.

Here's some more information:

Use the EnableClientScript property to specify whether client-side validation is enabled.

Validation controls always perform validation on the server. They also have complete client-side implementation that allows DHTML-supported browsers (such as Microsoft Internet Explorer 4.0 and later) to perform validation on the client. Client-side validation enhances the validation process by checking user input before it is sent to the server. This allows errors to be detected on the client before the form is submitted, avoiding the round trip of information necessary for server-side validation.

By default, this value is set to true, which enables client-side validation if the browser supports it. You can disable client-side validation on a control-by-control basis. This is useful if dynamic updating on the client creates problems with the layout of the page, or if you want to execute some server code before validation takes place.

0
Keep
2/19/2009 3:57:18 AM

Read this

http://msdn.microsoft.com/en-us/library/aa479045.aspx
We All move to our original place.
Don't forget.

Imran Baloch
0
imran_ku07
2/19/2009 5:12:05 AM

Hi,

If we want to validate something at the the server side, we could use the CustomValidator control to achieve. We make use of the CustomValidator_ServerValidate event of it to do some validation.

Please check the following code.

.aspx file

        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
        <asp:CustomValidator ID="CustomValidator1" runat="server"
            ControlToValidate="TextBox1" ErrorMessage="CustomValidator"
            onservervalidate="CustomValidator1_ServerValidate"></asp:CustomValidator> 

.cs file

   protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
    {
        if (args.Value == "123")
        {
            args.IsValid = true;
        }
        else
        {
            args.IsValid = false;
        }
    }

 

In addition, please refer to the following link below for the information about "CustomValidator".

http://msdn.microsoft.com/en-us/library/9eee01cx(VS.80).aspx

 

Please feel free to let me know if I’ve misunderstood anything.


Sincerely,
Zong-Qing Li
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as
Answer” if a marked post does not actually answer your question.
0
Zong
2/19/2009 6:21:23 AM
Reply:

Similar Artilces:

Validation Controls in .NET ( Client side or server side?)
 i have a very basic question. We have all these validation controls in asp.net ( required field, range validator and others)..my question is the required field validator is a server side control. So does that mean that it does a post back?..is it client side or server side control  The only controls that post back are buttons and other inputs where you set AutoPostback="True", such as a dropdownlist or a textbox.  Another way of posting back is using an UpdatePanel and placing a trigger in it for a specified control and/or event. All controls are considered clien...

client side validation vs server side validation
hello  i see a web form that consists of three controls :textbox,requiredfieldvalidator that weired to the textbox and a button within the click event of the button there is the following: if page.isvalid then response.redirect("Page is valid") else response.redirect("Page is not valid") end if according to my understandings: when the user does not fill anything in the textbox and then clicks the button the the page will not be submitted (i.e no request to the page will be happened or no postback will be happened) then no server event will be happened so it is sure when the us...

Server Side Validation vs Client Side Validation
If your page is using client side validation for required fields, expressions, etc.     What are the benefits or disadvantages of using 'extra' server side validation for max lengths, parsing, etc? Both have their Advantages and Disadvantages... so give this a read http://www.dotnetexpertsforum.com/viewtopic.php?t=172 Regards,Vinz"Code, Beer and Music" that's my way of being a programmer!How to get your Forum Question Answered | Blog | CodeASP.NET hi there, advantage: because you are using javascript some browsers for any reason may not sup...

Server side validation affecting client side validation
Hi there I have some client side validation that is working fine and enables/disables buttons based on user selections. This works great. However, when I perform server side validation using custom validators (like checking if the user has entered < HTML > tags or decimals in the integer boxes) and the server side validation returns isValid = false then all of the JavaScript validation that I've already done when the user clicked each control is lost. I don't understand why the enabled/disabled state of the control is not maintained.  What is calling the JavaScr...

avoiding redundant server-side validation after client-side validation
I see an inaccurate validation behavior on my asp.net (2.0) form. The EnableClientScript property of my validation control is set to True by default, so it performs the validation on clientside. But as soon as this occurs, it also performs the server-side validation, so the page refreshes. When the validation error occurs on clientside, it should not do the validation on serverside (I'm not calling Page.Validate() or doing Page.IsValid). In my past experience, asp.net handled this automatically, but I guess it's not always the ca...

client side and server side validation
http://samples.gotdotnet.com/quickstart/util/srcview.aspx?path=/quickstart/aspplus/samples/webforms/validate/validator8.src&file=CS\validator8.aspx&font=3 i am trying to do custom validation something similar to the above. I hv done the Severvalidate method in the code behind. What about the client validation? do i do it in code behind or in javascript as shown? The goal is to add text like this to the page:<script language='javascript'>function MyFunction(src, args){  // your logic to set args.IsValid here}</script>ASP.NET doesn't care if you typed it directly in...

Client side or server side validation???
I have multiple usercontrols each displayed by pressing a button and then change the apperance to a new user control and so on. I have to check that almost every field in this user controls have a value entered, and then indicate (e.g. with a red star) those textboxes that does'nt have a value entered. How should I do this in the best way, client side or server side with some validator? I have in mind that when using a server side validator, it may dissapear when making a postback. But I'm not sure, and I assume there is a way to come around this problem?What do you all say? Client side or s...

Validations client side or server side ???
Where should the validations (Required field, range, etc.) be done in an web page client side or server side?  As per my knowledge most of the validations are on client side using javascript, unfortunately it won't work if someone has disabled their browsers javascript option. what do we do in this case? Any suggestion please. Both... Client-side for rich client experience. Server-side for data validation and for clients who have disabled javascript. *Always* validate on the server side. You will still get the benefits of client-side validation on browsers setup to handle th...

validation, is it better to have client side or use server side validator controls
 Hi All. I want to do validation on text boxes etc. Is it better to do client side validation or just use the server side validation controls?   Hi!  If for server side controls you mean RequiredFieldValidator, CompareValidator, RegularExpressionValidator, etc.. i can tell you that they use client and server validation. For instance if you use a RequiredFieldValidator, on the client will be a validation, but on the server this condition will be evaluated again. Probably one of the objetives of this is deal with client with javascript disabled. Of course I ...

When do the validators kick in? Are they server side or client side?
 Hello,I am confused. I was under the impression that asp.net validators work on the client side.But I was confused when I set the enabled property of validator to false and then the validator did not work. (RegularExpressionValidator1.Enabled = false;)But the other confusing thing to me is that if the validators  work on the server side then when don't i see the page refresh like on other postback events? Kindly throw some light.Thanks!   Validators always work on the server side (assuming they're enabled), but also work on the client side if EnableClientScript is t...

SERVER SIDE DATA VALIDATION ON CLIENT SIDE
I wonder if this is the right forum to post this question because it is an issue about both server and client side processing. I am developing a web application (online store) which will run in a hosting company. Users accessing this app will be able to place orders with one limitation; the store has a schedule to accept orders. For example, it can be open from 8AM to 10PM and/or it can be closed on Mondays. I just can't validate time and/or day directly because time zone may lead to wrong results. So I thought about getting the schedule information, which is saved in my database, ...

Client-side validation works, but server-side does not.
Hey all,I have got this text box control on my webform, which has two validators.. 1. RegularExpressionValidator and 2. CustomValidator.Now, RegularExpressionValidator control works if I enable client-script. But somehow it does not work for server-side validation. Any idea why this is happening? This happens to another textbox control on other web form as well which has similar coding. So, to enable the validation at present I can only do client-side validation I guess.  1 <TD> 2 <anthem:TextBox id="txtDatePlannedSurgery" CssClass="aspText" Runat="server" AutoCal...

Validation Conrols: Client Side or Server Side?
Hi Folks, I am just wondering if the validation controls, use javascript...or server side code behind...Clearly, I would prefer it be server-side, because i'm concerned that a potential evil-doer could by-pass the validation, by turning off JS.If the validation controls use JS --- can someone refer me to proper server side validation techniques (VB). Thanks, - Joel    "The truth is rarely pure and never simple."- Oscar Wilde, The Importance of Being Earnest ASP.NET validation controls always use server-side validation, with additional client-side...

Disabling Client Side and Server Side Validation
I have a page which contains a User ID and Password field which have RequiredFieldValidators against them. The page can also load a User Control which contains another field which also has a RequiredFieldValidator against it. When I submit the form I use the ValidatorEnable function to disable the validator, on the User Control Page, when the user is signing in. This works fine on the client side but the page fails on the server side as I presume it does not know that I have disabled the control from the client side. Can anyone tell me the best way to solve this problem. Thanks M...

Web resources about - form double validation- server side and client side - asp.net.getting-started

Cross-validation (statistics) - Wikipedia, the free encyclopedia
is a model validation technique for assessing how the results of a statistical analysis will generalize to an independent data set. It is mainly ...

Serena Williams eyes history, Caroline Wozniacki craves validation in women's US Open final
As Serena Williams eyes another slice of tennis history, Caroline Wozniacki is craving validation with a watershed US Open final triumph on Sunday ...

Travers Duncan asks High Court to strike down ICAC validation laws
ICAC could be sent back to the High Court as a challenge to new laws validating corruption findings looms.

Adam Scott proclaims Texas win as validation of No.1 ranking
... No.1 golfer, beating American Jason Dufner in the third hole of a play-off at the Colonial event. "It's a good feeling and maybe some validation ...

Hollande to sign gay marriage bill after Constitutional Council's validation
Hollande to sign gay marriage bill after Constitutional Council's validation People's Daily Online ... 26, 27, 28, 29, 30, 31. Jan, Feb, Mar, ...

Marketers, Get Ready for the 'Validation Era'
The public brands included has been engaging in a "friends" arms race. But there are signs that we know we overdid it.

Validation and Uncertainty
What an extraordinary conversation I had recently on Twitter. It started with Neil Killick’s statement that we should not consider our stories ...

Nvidia Icera 410 LTE Modem Passes AT&T Network Validation
... Today's news is a small step and logical precursor toward both goals, Nvidia's Icera 410 LTE and HSPA+ baseband has passed AT&T's network validation ...

Ting’s Q1 Subscriber Growth Suffers from Sprint’s New Unlocking Validation Process
Back in February, Sprint updated the process it uses to validate unlocked devices that customers want to utilize on other carriers or one of ...

[Android M Feature Spotlight] Stricter APK Validation Now Actually Checks If All Of An APK's Files Are ...
While you might file this one under "really? We weren't doing this already?" if you're a security expert, Google has added stricter validation ...

Resources last updated: 12/11/2015 2:42:17 PM