且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用C#在ASP.NET中创建消息框

更新时间:2023-12-05 23:50:58

要使您的Web应用程序高效,可以添加一个名为MessageBox的类.在您的AppCode文件夹中.
请点击此链接
www.codeproject.com/KB/webforms/AspNetMsgBox.aspx [ ^ ]
To make your web application efficient you can add one class named MessageBox in your AppCode folder.
please cheak this link
www.codeproject.com/KB/webforms/AspNetMsgBox.aspx[^]


尝试一下,

Try this,

public void MsgBox1(string msg, Page refP)
   {
       Label lbl = new Label();
       string lb = "window.alert(''" + msg + "'')";
       ScriptManager.RegisterClientScriptBlock(refP, this.GetType(), "UniqueKey", lb, true);
       refP.Controls.Add(lbl);
   }



将您的函数放在cs文件(即yourclass.cs文件)中,然后调用以下函数:



Put your function in cs file(i.e. yourclass.cs file)And call the function like:

MsgBox1("Your Message",this);


我建​​议您使用Label控件,并使用红色或绿色.

另一个选择是使用Javascript警报.
I would suggest that you use Label control and use color red or green.

Another option is to use Javascript alert.