2017-08-14 74 views
0

我創建了一個名爲Welcome.aspx的頁面。在該頁面上,我添加了一個按鈕,在該按鈕上單擊事件頁面應該重定向到另一個頁面,例如UserRegisteration.aspx頁面,但UserRegisteration.aspx頁面應該可以由Team Lead,Manager等特定用戶訪問。如果除此之外的用戶單擊該按鈕並嘗試訪問UserRegisteration.aspx頁面,則應該生成錯誤消息。如何向特定用戶提供訪問asp.net中的網頁的權限?

請教我如何達到以上要求?在此先感謝

+0

你如何識別用戶類型? – AsifAli72090

+0

基於團隊領導的角色,經理 – svs

回答

0

使用此按鈕代碼:

protected void Button1_Click(object sender, EventArgs e) 
    { 
      string userType = "Team Lead"; // set user type 
      if (userType=="Team Lead" || userType=="Manager") 
      { 
       Response.Redirect("UserRegisteration.aspx"); // redirects to specified page 
      } 
      else 
      { 
       // shows error message 
       ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('You are not a valid user!')", true); 
      } 

    } 
+0

感謝您的解決方案,但如何識別哪個特定用戶點擊了按鈕?無論用戶是正常用戶,還是管理員和團隊在登錄頁面中領導 – svs

+0

,都可以指定userType,然後將其存儲在sesseion中。 – AsifAli72090

相關問題