如何使用C#在ASP.NET中创建消息框 [英] How to create a Message Box in ASP.NET using C#

查看:82
本文介绍了如何使用C#在ASP.NET中创建消息框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在asp.net Web应用程序中创建一个消息框..

I want to create a message box in asp.net web application any help..

推荐答案

要使您的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.


这篇关于如何使用C#在ASP.NET中创建消息框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆