Validation Controls in .NET ( Client side or server side?)

 i have a very basic question. We have all these validation controls in ( 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? it client side or server side control 

10/1/2007 8:48:31 PM
📃 93655 articles.

💬 3 Replies

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 client controls because the control is rendered as html to the client's browser. 

Server controls are any controls that have runat="server" in their tags.  This means that the control will have an object created to represent it in the code-behind, whether it is an ASP.NET webcontrol or a standard HTML control (which ASP.NET will render an HTMLControl object for).


The validators do not post back.  The validators can be configured to emit javascript on the client's end, so validation can take place without posting back to the server, but you should still validate the page on postback before running any code. (Hackers can change javascript, so the javascript is only there as a convenience to the user-- you still need a safety net at the server.)

Before executing code from the control that posted back, check the Page.IsValid property to make sure that it is true.

MCP - Web Based Client Development .NET 2.0
10/1/2007 9:54:24 PM
Thanks for your reply.
My question then is that if validation controls are client side controls then why do we have to put runat="server"
Does that mean that validation controls can work both client side and server side.

Also i have noticed that If i turn off the JavaScript then these validation controls become useless.
Is there a way to check if client side JavaScript is turned on? or how can use the Page.Isvalid property.

Thanks again
10/2/2007 1:22:38 PM

We put "runat=server" as it is a server control. Do you see the same tag in the HTML of the Page? NO. The tag being runat=server is processed by .net and converted into the necessary javascript and HTML code which saves you from writing all that code by yourself.

Q. Validators work on server side or client side.
A. Actually they are meant for both the sides. Validators have a property "   EnableClientScipt" which by default is True. If you set it as false the validaton would occur server side only (which always takes place). And the reason is that it might be that the browser doesn't support javascript so in that case client side validations will fail but your validators execute on server side as well so that they execute the task they are intended to.


Hope I was able to relax your confusion to some extent :) 



I compete with myself to motivate me!!

Do not forget to mark posts, that help you, as "Answer".
10/2/2007 1:32:24 PM