如何在默认页面顶部插入登录控件 [英] how can i insert login control on the top of default page

查看:124
本文介绍了如何在默认页面顶部插入登录控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的母版页中,当我单击它时,该页将重定向到登录页.现在,我想在主页本身中创建登录控件,以便用户不必一次又一次访问登录页.我想我无法在母版页中创建登录控件.它必须在默认页面中,但是我如何才能将该控件放在页面顶部.我也曾在母版页中使用过登录控件,但后来我的其他控件离子登录页无法正常工作

in my master page there is a login status when i click on it the page is redirected to login page.now i want to create login control in the home page itself so that users dont have to visit loginpage again and again..i guess i cant create the login control in the masterpage .it has to be in the default page but then how can i put that control on the top of the page . i have also used login control in masterpage but then my other control ion login page doesnt work properly

推荐答案

您可以通过在标记中添加类似的内容来将Login控件添加到母版页面中

You can add a Login control to your master page by adding something like this to the markup

<asp:Login runat="server" ID="MyLoginControl" />

或者我将登录控件从工具箱中拖到母版页的设计器上.

Or my dragging the Login control onto the master page's designer from the Toolbox.

要在用户登录时隐藏登录控件,请将以下代码添加到母版页代码的后面:

To hide the login control when the user is logged in, add this code to the master page code-behind:

if (Page.User.Identity.IsAuthenticated)
{
   MyLoginControl.Visible = false;
}

这篇关于如何在默认页面顶部插入登录控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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