簡體   English   中英

我如何在asp.net中給消息警報框

[英]How can i give message alert box in asp.net

我該如何在asp.net網頁上給消息框警報,方法是按“ if”語句和“ else”中的成員身份檢查用戶名和密碼,所以我應該將警報框顯示為“輸入有效的用戶名和密碼”(我選中了“ if '但我不知道如何在'else'中發出警報消息)

if (Membership.ValidateUser(txtUserName.Text, txtPassword.Text))
           {

           }
           else
           {
               // Here i have to display message box alert
           }

請幫助我盡快解決此問題。

嘗試這樣...在您的else部分中添加以下代碼...

ClientScript.RegisterClientScriptBlock(this.GetType(),"alert","Your Message",true);

嘗試這個

ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "msg", "alert('your message')", true); 

將此功能用於通用

public void MessageBox(string msg)
        {
            Page page = HttpContext.Current.Handler as Page;
            ScriptManager.RegisterStartupScript(page, page.GetType(), "err_msg", "alert('" + msg + "');", true);
        }

您可以使用Microsoft Ajax模態彈出窗口檢查此鏈接http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/ModalPopup/ModalPopup.aspx

嘿警報彈出窗口根據條件進行注冊。

如果要在頁面加載中注冊,請使用此功能。

ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "msg", "alert('your message')", true);

如果要注冊任何特定的塊,請使用此功能。

ClientScript.RegisterClientScriptBlock(this.GetType(),"alert","Your Message",true);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM