Last post Aug 07, 2018 12:52 PM by mudassarkhan
Aug 04, 2018 03:52 AM|vijaylakshmi|LINK
This doubt may sound silly,
but i had to ask.
I have a textbox which must be filled, i.e an error message has to be prompted when it is empty. This error message can be generated in two ways
first method : using client side validation i.e JQuery (in my case as i have started using it quite extensively)
second method : using asp text box requiredfield validator.
If i use jquery to check textbox value, it means that i validate without server event like button click.
if i use requiredfieldvalidator, then erroe message is triggerd at a button click i.e server side event.
Am i correct in my understanding?
Did i understand the difference correctly?
Aug 04, 2018 05:22 AM|oned_gk|LINK
AFAIK, by default EnableClientScript property is true. It's completely client side validation.
Aug 04, 2018 06:52 AM|vijaylakshmi|LINK
Then why to use Jquery then??
Am i correct in asking this question?
Aug 04, 2018 09:47 AM|oned_gk|LINK
RequridFieldValidator is a part of ASP.Net Controls,
jQuery is another easy way to make validation work, it's not part of ASP.Net
Aug 06, 2018 09:29 AM|Ackerly Xu|LINK
Jquery and requiredFieldValidator both run at client side.
If you add response.write(“something”) to your button’s click event , you will find “something” doesn’t appear when you click the button with the textbox empty , which proves the requiredFieldValidator doesn’t cause a postback ,so the it runs at client
<asp:textbox runat="server" ID="text"></asp:textbox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator"
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
protected void Button1_Click(object sender, EventArgs e)
If the event fires at server side , wrong data will be sent to server which will waste time and network flow, so it is better to run it at client side.
Asp.net controls doesn’t necessarily mean doing a postback , although a postback is normally with asp.net control.
Jquery could be used with any language at server side and with any framework of server side , while controls in web form only applies to web form in c#.
also manipulate html through web form controls .
Aug 07, 2018 07:00 AM|vijaylakshmi|LINK
So basically, Jquery validation or requiredfieldvalidator both are run on client side and both are used for the same purpose.
So it is completely the programmer's choice to choose between the two.
Am i right??
Aug 07, 2018 07:01 AM|vijaylakshmi|LINK
One more doubt, if requiredfiledvalidator is client side, then why do we have runat =server tag??
Aug 07, 2018 07:38 AM|oned_gk|LINK
AFAIK, runat="server" mean it's server control rather than static html
<div id="test" runat="server"></div>
You can modify the control from server codes
test.Attributes("class") = "row"
<a href="~/folder/filename.aspx" runat="server">Test</a>
you will get deferent result for above href when using or not runat="server"
All asp.net controls need runat="server"
ASP.Net will render the validation control to generate client validation as HTML.
Aug 07, 2018 12:52 PM|mudassarkhan|LINK
For Both Server Side and Client Side valdiation. You can use Custom Validator
ASP.Net Custom Validator Server Side validation
using OnServerValidate event