2012-04-19 88 views
0

會打開一個新的彈出窗口,但會將其重定向到登錄頁面,並且基本頁面也將無法通過顯示不正確的密碼進行登錄。要求:登錄後我們需要一個彈出窗口,瀏覽器上沒有任何BACK按鈕。如何在用戶登錄(登錄控件)後打開一個新窗口?

<asp:Content ID="LoginContent" ContentPlaceHolderID="LoginContent" runat="server"> 
     <asp:UpdatePanel ID="LoginUpdatePanel" runat="server" UpdateMode="Conditional"> 
     <ContentTemplate> 
      <asp:Panel Width="100%" runat="server" ID="LoginPanel" HorizontalAlign="Center" DefaultButton="MainLogin$LoginButton"> 
       <asp:Label ID="LoginMessageValue" runat="server"></asp:Label> 
       <asp:Login RememberMeSet="false" ID="MainLogin" OnLoggedIn="MainLogin_LoggedIN" OnAuthenticate="Login_Click" runat="server" SkinID="standardLoginObject" EnableTheming="True" 
        TextBoxStyle-Width="150px" DisplayRememberMe="false"> 
       </asp:Login> 
      </asp:Panel> 
     </ContentTemplate> 
    </asp:UpdatePanel> 
</asp:Content> 

代碼背後:

Protected Sub Login_Click(ByVal sender As Object, ByVal e As System.EventArgs) 
     'OnAuthenticate = "Login_Click" 
     ' ScriptManager.RegisterClientScriptBlock(Me.Page, Me.GetType, "error", "window.open('~/workflow/Worklist2.aspx', 'mywindow', 'status=1,toolbar=0');", True) 
     Try 
      Common.UserObject = System.Web.Security.Membership.GetUser(MainLogin.UserName) 

      Dim _userID As Integer = Common.UserObject.ProviderUserKey 
      Common.InitializeSession(_userID, nameSpaceURI) 
      Dim _role() As String = System.Web.Security.Roles.GetRolesForUser(Common.UserObject.UserName) 
      If _role.Length = 0 Then 
       Common.ClearSession() 
       Response.Redirect(ConfigurationManager.AppSettings("LoginPath"), False) 
       'MainLogin.FailureText = "Please contact the customer service to review your account setup." 
       'ClientScript.RegisterClientScriptBlock(Page.GetType, "Error", "alert('Please contact the customer service to review your account setup.')", True) 
      End If 
      ScriptManager.RegisterClientScriptBlock(Me.Page, Me.GetType, "success", "window.open('../workflow.aspx', 'mywindow', 'status=1,toolbar=0'); window.resizeTo(screen.availWidth,screen.availHeight); window.moveTo(0,0); ", True) 
     Catch ex As Exception 
      SaveException(ex) 
     End Try 
    End Sub 

回答

0

我認爲你真正的問題是,你想顯示錯誤頁面這也需要用戶進行身份驗證才能看到它。

您應該將錯誤頁面移動到公開可見的位置。

您可以指定此行爲在你的web.config:

<configuration> 
    <location path="~/errorpage.aspx"> 
     <system.web> 
     <authorization> 
      <allow users="?"/> 
     </authorization> 
     </system.web> 
    </location> 
</configuration> 
相關問題