Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
HI,
 
I have a doubt in Asp.net MVC3 application.i am creating a login page and login page contains a javascript function (index.chtml - View) and the javascript function contains the validation of controls and displaying the Errors.
 
Here i need the code for calling javascript function from my controller page.
 

Please help me.....
 
Thanks in advance..
 

Dil
Posted 26-Jul-12 2:09am
dilzz1.2K
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

First of all you can not call javascript from controller. Javascript runs on client side, your controller is running on the server.
Although you can make the view execute code on behalf of the server.
 
If speaking from validation in general, you can do client and server side validation in MVC3, or you can (should) use both. If you use server side validation, the page is posted, thus refreshed. If you use client side one, you need to send the logic on client side. Validating credentials is not really possible this way - and this is called authentication, not validation.
 
If I understand your post correctly, you want authentication to look and feel like client side validation. Than you need remote validation[^].
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 8,149
1 Sergey Alexandrovich Kryukov 7,287
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,910


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 26 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100