Expand the login control in Asp.net 2.0

Source: Internet
Author: User
In Asp.net 2.0, the login logon control is a good choice, but sometimes it needs to be extended. For example, in an OA system, sometimes you need to select which subsidiary of the group the login user belongs to. In this way, in addition to the user name and password, you also need to have a dropdownlist and set it to the names of all subsidiaries of the group, how should we achieve this?
We can first select login control and convert it to a template column, and add a dropdownlist to it, as shown below:

<Asp: Login ID = "login1" runat = "server" onloggingin = "loginlogs loggingin">

<Layouttemplate>

....

<Asp: dropdownlist id = "companies" runt = "server"…>

....

</ASP: dropdownlist>

....

</Layouttemplate>

</ASP: Login>
Then, in the authenticate event of the login control, write the followingCode:

Protected void login1 _ authenticate (Object sender, authenticateeventargs E)

{

String company:

 

Dropdownlist companies = login1.findcontrol ("Companies") as dropdownlist;

If (companies! = NULL)

Company = companies. selectedvalue;

 

...

// Validate the user ..

E. Authenticated = true;

}

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.