What is Serverside Validations and Clientside Validations [Resolved]

Posted by Sravya under ASP.NET on 11/7/2012 | Points: 10 | Views : 1386 | Status : [Member] | Replies : 5
Hi...
What is Serverside Validations and Clientside Validations. Can any one tell with one example...
and Show the Exact Difference.....Using Code

Thanks & Regards
Sravya




Responses

Posted by: Kusumas on: 2/10/2013 [Member] Starter | Points: 50

Up
0
Down

Resolved

The client side validation runs in the browser where as server side validation runs on server. It actually check if the submitted data is correct or not. It is suggested that one should use both types of validation.
Clientside:
if ($(input[txtbox].val()== ''') {
alert('textbox value is mandatory') ;
return false;
}
else {
return true;
}
ServerSide:

protected void btn_OnClick(object sensder EventArgs e)
{
if(txtbox.text==string.empty)
{
lblerror.text="textbox value is mandatory";
}
else
{
//write your code here.................
}
}

Sravya, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sandhyab on: 11/7/2012 [Member] Starter | Points: 25

Up
0
Down
Hi sravya
Asp.net has introduced a new type of validations controls which can validate controls both on the client side and server side.

1) In Client side validations the validations are performed by the client browser using client side script.
In server side validations the validations are performed by the server code developed in C# or VB.

2)Client side validations are not secured,where server side validations are secured.

3)Client side validations give quick response.

4)Client side validations are browser dependent but where as server side validations are browser independent.

5)Client side validation logic is having limited resources but where as server side validations logic contains more resources because any .NET language can be used.

Thanks & Regards
Sandhya

Sravya, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kalaikathiravan on: 11/7/2012 [Member] Starter | Points: 25

Up
0
Down
client side validation:
That means codes are executed by client side browser. Its not secure but executed faster than server validation. Its like client view type easily view the coding
open browser->right click the mouse->and then click view source
server side validation:
that means codes are executed in server. Just you submit your page and then your request send your server and then validate your page example asp.net validation controls. server side validation its a very secure type validation
Client are could not be view this code

Sravya, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sravya on: 11/7/2012 [Member] Starter | Points: 25

Up
0
Down
Hi sandya...
I need Example... I don't want differences...
just I need Exact Code..


Thanks & Regards
sravya

Sravya, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Saratvaddilli on: 11/8/2012 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi sravya
client side validation is one which we do in the aspx page using javascript

function TextBoxDCountyClient(sender, args) {

var v = document.getElementById('<%=TextBoxDTownCity.ClientID%>').value;
if (v == '') {
args.IsValid = false; // field is empty
}
else {
// do your other validation tests here...
}
}

server side validation is one which we do validation in the code behind

protected void TextBoxDTownCity_Validate(
object source, ServerValidateEventArgs args)
{
string v = TextBoxDTownCity.Text;
if (v == string.Empty)
{
args.IsValid = false; // field is empty
}
else
{
// do your other validation tests here...
}
}


Thanks and Regards
V.SaratChand
Show difficulties that how difficult you are

Sravya, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response