您现在的位置: PQ秀秀网 >> 网络编程 >> ASP.NET编程 >> 正文 用户登录 新用户注册
asp.net 2.0中扩展login控件
作者:佚名    教程来源:不详    点击数:加载中...    更新时间:2008-4-3 字体:[ ]
添加到收藏: 添加到百度收藏  收藏到QQ书签  添加到雅虎收藏  添加到新浪ViVi  添加到天极网摘  添加到和讯网摘

 asp.net 2.0中,login登陆控件是个不错的选择,但有时需要扩展该控件,比如,在一个OA系统中,有时要选择登陆的用户所在的是集团的哪一个子公司,这样,除了用户名,密码外,还需要有个dropdownlist,设置为该集团的所有子公司名,象这样应该如何实现呢?
      我们可以首先选择login control,并且将其转换为模版列,在其中加上一个dropdownlist,如下:


   <asp:Login ID="Login1" runat="server" OnLoggingIn="Login1_LoggingIn">
         <LayoutTemplate>
           ….
         <asp:DropDownList id=”companies” runt=”server” …>
           ….
         </asp:DropDownList>
          ….
          </LayoutTemplate>
  </asp:Login>

  然后在login控件的Authenticate事件中,写入如下代码:
  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;

  }


 

教程录入:andy    责任编辑:andy 
  网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)