Click here to Skip to main content
11,922,320 members (40,121 online)
Rate this:
Please Sign up or sign in to vote.

I have a doubt in 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..

Posted 26-Jul-12 2:09am
Rate this: bad
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[^].

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

  Print Answers RSS
0 OriginalGriff 493
1 Dave Kreskowiak 285
2 Sergey Alexandrovich Kryukov 243
3 Richard MacCutchan 155
4 ppolymorphe 135
0 OriginalGriff 7,231
1 KrunalRohit 4,530
2 Sergey Alexandrovich Kryukov 3,356
3 George Jonsson 2,865
4 Suvendu Shekhar Giri 2,216

Advertise | Privacy | Mobile
Web04 | 2.8.151120.1 | Last Updated 26 Jul 2012
Copyright © CodeProject, 1999-2015
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