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;
}