LoginView.LoggedInTemplate 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定樣板,這個樣板會針對已登入網站,但不屬於 RoleGroups 屬性所指定其中一個角色群組之成員的網站使用者顯示。
public:
virtual property System::Web::UI::ITemplate ^ LoggedInTemplate { System::Web::UI::ITemplate ^ get(); void set(System::Web::UI::ITemplate ^ value); };
[System.ComponentModel.Browsable(false)]
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
[System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.LoginView))]
public virtual System.Web.UI.ITemplate LoggedInTemplate { get; set; }
[<System.ComponentModel.Browsable(false)>]
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
[<System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.LoginView))>]
member this.LoggedInTemplate : System.Web.UI.ITemplate with get, set
Public Overridable Property LoggedInTemplate As ITemplate
屬性值
要顯示的 ITemplate。
- 屬性
範例
下列程式代碼範例會 LoggedInTemplate 使用範本來顯示已登入用戶個人化信息的連結。
<%@ Page Language="C#"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<table style="text-align:center; width:300px; background-color:#fffacd">
<tr style="background-color:#dcdcdc">
<td>Personal content</td>
<td>
<asp:LoginStatus id="LoginStatus1" runat="Server"></asp:LoginStatus>
</td>
</tr>
<asp:LoginView id="LoginView1" runat="server">
<AnonymousTemplate>
<tr>
<td colspan="2">
<a href="createUser.aspx">Sign up</a> to personalize your account.
</td>
</tr>
</AnonymousTemplate>
<LoggedInTemplate>
<tr>
<td>
<asp:LoginName id="LoginName1" runat="Server"
FormatString="Welcome {0}">
</asp:LoginName>
</td>
<td>
<a href="manageAccount.aspx">Edit info...</a>
</td>
</tr>
<tr>
<td colspan="2">
* Check email * Add a link * Local weather *
</td>
</tr>
</LoggedInTemplate>
</asp:LoginView>
</table>
</form>
</body>
</html>
<%@ Page Language="VB"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<table style="text-align:center; width:300px; background-color:#fffacd">
<tr style="background-color:#dcdcdc">
<td>Personal content</td>
<td align="right">
<asp:LoginStatus id="LoginStatus1" runat="Server"></asp:LoginStatus>
</td>
</tr>
<asp:LoginView id="LoginView1" runat="server">
<AnonymousTemplate>
<tr>
<td colspan="2">
<a href="createUser.aspx">Sign up</a> to personalize your account.
</td>
</tr>
</AnonymousTemplate>
<LoggedInTemplate>
<tr>
<td>
<asp:LoginName id="LoginName1" runat="Server"
FormatString="Welcome {0}">
</asp:LoginName>
</td>
<td align="right">
<a href="manageAccount.aspx">Edit info...</a>
</td>
</tr>
<tr>
<td colspan="2">
* Check email * Add a link * Local weather *
</td>
</tr>
</LoggedInTemplate>
</asp:LoginView>
</table>
</form>
</body>
</html>
備註
當符合下列兩個條件時,屬性 LoggedInTemplate 會顯示給網站使用者:
使用者不屬於 屬性中 RoleGroups 定義的角色群組。
屬性 LoggedInTemplate 會指定已驗證網站用戶的預設範本。 如果您尚未設定角色管理, LoggedInTemplate 則是唯一可供已驗證使用者的範本使用。 如需設定角色管理的詳細資訊,請參閱 瞭解角色管理。