How to implement login view as jQueryUI dialog box in ASP.Net MVC

I saw a few examples of such things, and I also looked at the KiGG application, which also uses a dialog box to display the login window. I'm new to MVC, but have improved a bit, and I want to add some candy for a demo that I need to complete next week.

Does anyone have a simple example or can I describe the steps I need to take to create a login window to the jQueryUI dialog box?

I have some parts that I think ... I think I need a partial view on the main page (for example, Kigg), so that at any time I click on the controller that needs authentication, on the main page it will be considered its main page.

Any help would be appreciated.

+4
source share
1 answer
  • Create a regular html form in the jQuery interface dialog box. An example is here .

  • Validate jQuery form to submit form via ajax. Use jQuery validation in combination if desired. Example:

    function isValid (formData, jqForm, options) {return $ (jqForm [0]). valid (); }

    function loggedIn () {alert ("You are logged in"); }

    var formOptions = {beforeSubmit: isValid, success: loggedIn, url: '/ your / mvc / action / on / login / controller', type: 'post'};

    var validateOptions = {submitHandler: function (form) {JQuery (form) .ajaxSubmit (formOptions); $ ("# Dialog") Dialog (). }, Messages: {email: "Email required", password: "Password required"}};

    $ ("# LoginForm") checks (validateOptions).

  • Create a login action for the JsonResult controller account and publish the form for this action (it must be https).

+3
source

Source: https://habr.com/ru/post/1302030/


All Articles