我如何在asp.net中提供消息警报框

时间:2022-04-05 06:48:21

how can i give message box alert in asp.net Webpage By checking the username and password by membership in 'if' statement and in 'else' i should display the alert box as"enter valid username and password"(i checked the 'if' but i don't know how to give alert message in 'else')

如何在asp.net网页中给出消息框提示通过'if'语句中的成员资格检查用户名和密码,在'else'中我应该将警告框显示为“输入有效的用户名和密码”(我检查了'if '但我不知道如何在'else'中提供警报信息)

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

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

Please help me to solve this issue as soon as possible.

请帮我尽快解决这个问题。

5 个解决方案

#1


2  

Try like this...Add following code in your else part...

试试这样......在你的其他部分添加以下代码......

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

#2


0  

Try this

尝试这个

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

#3


0  

you can use the Microsoft Ajax modal popup check this link http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/ModalPopup/ModalPopup.aspx

您可以使用Microsoft Ajax模式弹出窗口检查此链接http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/ModalPopup/ModalPopup.aspx

#4


0  

Hey Alert popup is registered to based on condition.

根据条件注册嘿警报弹出窗口。

If you want to registered on Page load use this.

如果要在Page load上注册,请使用此选项。

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

If want to be registered any specific block use this.

如果想要注册任何特定的块使用此。

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

#5


0  

use this function for generic

使用此函数进行通用

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

#1


2  

Try like this...Add following code in your else part...

试试这样......在你的其他部分添加以下代码......

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

#2


0  

Try this

尝试这个

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

#3


0  

you can use the Microsoft Ajax modal popup check this link http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/ModalPopup/ModalPopup.aspx

您可以使用Microsoft Ajax模式弹出窗口检查此链接http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/ModalPopup/ModalPopup.aspx

#4


0  

Hey Alert popup is registered to based on condition.

根据条件注册嘿警报弹出窗口。

If you want to registered on Page load use this.

如果要在Page load上注册,请使用此选项。

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

If want to be registered any specific block use this.

如果想要注册任何特定的块使用此。

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

#5


0  

use this function for generic

使用此函数进行通用

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