ASP. NET-how to: display different information to anonymous users and logon users

Source: Internet
Author: User

By adding Loginview Controls display different information to anonymous users and login (authenticated) users. Loginview The control contains two templates: one for displaying information to anonymous users and the other for displaying information to logged-on users. (You can also use Rolegroups The attribute contains a template based on the role name .) The control automatically determines whether the user is authenticated and displays the corresponding template.

 

1 , in Asp. net in the" design "view of the page, select a loginview drag the control to the page.

 

2 If" Loginview If the task panel is not displayed, right-click the control and Click Show Smart tag to display Loginview Task panel. By default, this control displays Anonymoustemplate .

 

3 Add static text and controls visible to Unlogged users, for example, it is used to log on to a user, restore the password, or create a new user id login control.

4 , in" loginview task" menu, select loggedintemplate .

5 Add static text and controls visible to authenticated users, for example, formatstring set the property to the loginname control.

<Asp: loginview id = "loginview1" runat = "server">

<Loggedintemplate>

<Asp: loginname id = "loginname1" runat = "server"

Formatstring = "Welcome, {0}"/>

<Br/>

<Asp: hyperlink id = "hyperlink1" runat = "server"

Navigateurl = "~ /Memberpages/changepassword. aspx ">

Change Password

</ASP: hyperlink>

</Loggedintemplate>

<Anonymoustemplate>

<Asp: Login ID = "login1" runat = "server"

Createusertext = "Create a new user ..."

Createuserurl = "~ /Register. aspx"

Passwordrecoveryurl = "~ /Recovery. aspx"

Usernamelabeltext = "E-mail address:"/>

</Anonymoustemplate>

</ASP: loginview>

TheCodeFor example Anonymoustemplate And Loggedintemplate In the "Source" view Loginview Control.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.