对于ASP.NET 2.O页面jQuery的登录模式弹出 [英] jQuery Login modal popup for ASP.NET 2.o Page

查看:106
本文介绍了对于ASP.NET 2.O页面jQuery的登录模式弹出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.NET网页(不MVC)(HomePage.aspx)和另一页(PRiceList.aspx)。我有我的主页page.So登录功能,当用户在该网站登录,就可以转到页pricelist.aspx容易使用homepage.If链接有人正在进入与出登录的页面,我想说明一个模式登录框(背景禁用)登录。我看到这个在jQueryUI的site.Can任何一个告诉我如何在我的网站impement呢?有没有在这任何安全问题,因为我使用的JavaScript使用这种方法(我不知道),当发送用户凭据到现场。请指教。在此先感谢

I have an ASP.NET web page(Not MVC ) (HomePage.aspx) and another page (PRiceList.aspx).I have a login feature in my Home page.So when a user logged in the site, They can go to the pricelist.aspx page easily using a link in homepage.If some one is entering the page with out logging in , I want to show a modal login box (background disabled) to login . I saw this in jqueryui site.Can any one tell me how to impement this in my site ? Is there any security problem in this since i am using the javascript to send the user credentials to the site when using this method (I am not sure) . Please advice. Thanks in advance

推荐答案

jQuery的模态对话框形式是你的路要走这里。我做了一个测试应用程序做你想要做什么用,效果不错。

jQuery Modal Form Dialog is your way to go here. I made a test app doing what you wanted with it and it worked well.

标记为您的ASPX页面:

Markup for your ASPX page:

<div id="dialog" title="Please Login">
        <asp:Login ID="login" runat="server" />
</div>

所需的页面的Javascript:

Javascript needed for the page:

$(document).ready(function() {
$("#dialog").dialog({
    bgiframe: true,
    autoOpen: false,
    height: 300,
    modal: true,
    buttons: {
        Cancel: function() {
            $(this).dialog("close");
        }
    },
    close: function() {
        allFields.val("").removeClass("ui-state-error");
    }
});

var isAuthenticated = $("#isAuthenticated").val();
if (isAuthenticated && isAuthenticated == "false") {
    // Display the modal dialog.
    $("#dialog").dialog("open");
}});

code后面我aspx页面上使用的:

Code behind I used on the aspx page:

ClientScript.RegisterHiddenField("isAuthenticated", "false");

您会给它真的还是假的,这取决于如果用户通过身份验证,所以的JavaScript就知道到显示登录或没有。

You would give it true or false, depending on if the user was authenticated, so the javascript would know to display the login or not.

现在有关安全。登录不会由JavaScript来完成,因为用户会打的登录页面上的按钮,它会回发到像正常服务器。如果你想使用Ajax,你必须检查出的jQuery $就方法。

Now about the security. The login wouldn't be done by the javascript because the user would hit the button on that login page and it would post back to the server like normal. If you wanted to use ajax, you would have to check out the jQuery $.ajax method.

这篇关于对于ASP.NET 2.O页面jQuery的登录模式弹出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆