简体   繁体   English

如何在ASP.Net MVC中将登录视图实现为jQueryUI对话框

[英]How do i implement a login view as a jQueryUI dialog box in ASP.Net MVC

I've seen a few example of similar things and i've also looked at the KiGG application which also uses a dialog box to display the login box. 我已经看到了类似的一些例子,我也看了KiGG应用程序,它也使用一个对话框来显示登录框。 I'm pretty new to MVC but making some good progress and i'm looking to add a bit of candy for a demo i need to perform next week. 我对MVC很新,但取得了一些进展,我希望为下周需要演示的演示添加一些糖果。

Does anyone have an simple example or could describe the steps i need to take to make a login view appear in a jQueryUI dialog box ? 有没有人有一个简单的例子或可以描述我需要采取的步骤,使登录视图出现在jQueryUI对话框中?

I have some of the pieces i think ... I think i need a partial view to be in the master page (like Kigg) so that at anytime i hit a controller which needs authenication the master page will deal with it. 我认为我有一些部分...我认为我需要部分视图才能进入母版页(如Kigg),以便在任何时候我点击一个需要验证的控制器,母版页将处理它。

Any help would be appriecated. 任何帮助都会被淹没。

  1. Create a normal html form within your jQuery UI dialog. 在jQuery UI对话框中创建一个普通的html表单。 Example here . 这里的例子。

  2. Hook up jQuery Form to submit the form via ajax. 连接jQuery表单以通过ajax提交表单。 Optionally, use jQuery validation in combination. (可选)结合使用jQuery验证 Example: 例:

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

    function loggedIn() { alert("You are logged in"); function loggedIn(){alert(“你已登录”); } }

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

    var validateOptions = { submitHandler: function(form){ jQuery(form).ajaxSubmit(formOptions); var validateOptions = {submitHandler:function(form){jQuery(form).ajaxSubmit(formOptions); $("#dialog").dialog(); $( “#对话”)对话框()。 }, messages: { email: "Email is required", password: "Password required" } }; },消息:{email:“需要电子邮件”,密码:“需要密码”}};

    $("#loginform").validate(validateOptions); $( “#登录表单”)验证(validateOptions)。

  3. Create a login action on your account controller returning JsonResult and post your form to this action (should be https). 在您的帐户控制器上创建一个登录操作,返回JsonResult并将您的表单发布到此操作(应该是https)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM