我有看似簡單的問題,並且在設計正確的解決方案時遇到困難。asp.net登錄 - 如何與信息提示inturrupt?
我有一個正常的asp.net登錄控制。當用戶登錄(併成功通過驗證),我想顯示一個類似的JavaScript消息提示:
警告:這是一個政府系統...等
有100萬和一個方法來做到這一點...但我真的想保持在我的登錄用戶控制。我玩了下面的方法,沒有運氣:
protected void OnAuthenticate(object sender, AuthenticateEventArgs e)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "warning", "alert('hello');", true);
}
protected void OnLoggingIn(object sender, LoginCancelEventArgs e)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "warning", "alert('hello');", true);
}
protected void OnLoggedIn(object sender, EventArgs e)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "warning", "alert('hello');", true);
}
看起來回傳頁面生命週期似乎是在擰我。
也許我應該考慮這個不同?
登錄頁面 - >(成功) - >警告消息頁面 - >用戶信息中心頁
任何意見將不勝感激。
謝謝!
-Josh
編輯:我也試着Page.ClientScript.RegisterClientScriptBlock( 「......」);
你是否在通過調用`Response.Redirect()`登錄後重定向用戶?這會導致任何註冊的JavaScript不被髮射。 – 2011-02-11 02:34:13