消息框在asp.net [英] Messagebox in asp.net

查看:114
本文介绍了消息框在asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在asp.net中一个简单的消息框,我尝试以下code。

  Me.Page.ClientScript.RegisterStartupScript(Me.GetType(),clientScript,<脚本>的javascript:警报('客户已经与相关
另一个事件');&下; /脚本>中)

但我有没有运气。其实我有一个DropDownList是一个UpdatePanel中应该通过一个消息抛出一个错误消息。我不知道为什么JavaScript的不工作。有没有使我们能够显示一个消息框简单的错误消息的任何其他方式。


解决方案

 的静态公共无效DisplayMessage(Control页面,string信息)
{
    字符串myScript的=的String.Format(警报('{0}');,味精);    ScriptManager.RegisterStartupScript(页面,page.GetType(),的MyScript,myScript的,真);
} DisplayMessage(这一点,客户已经与另一事件相关联);

I need a simple messagebox in asp.net, I tried the following code.

Me.Page.ClientScript.RegisterStartupScript(Me.GetType(), "clientScript","<script>javascript:alert('Guest already associated with 
another event');</script>")

but I had no luck. Actually I have a dropdownlist which is in a updatepanel it should throw an error message via a MessageBox. I don't know why javascript not working. Is there any other way by which we could show an simple error message in MessageBox.

解决方案

 static public void DisplayMessage(Control page, string msg)
{
    string myScript = String.Format("alert('{0}');", msg);

    ScriptManager.RegisterStartupScript(page, page.GetType(), "MyScript", myScript, true);
}



 DisplayMessage(this, "Guest already associated with another event");

这篇关于消息框在asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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