Web Asp.net 中的Messagebox 判断..
在web 中使用messagebox 进行交互判断性程序执行, 没有在win form 中那么方便。
例:想到做下面的效果,在asp.net 中我们应该么这做。
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server"> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Save" runat="server" Text="Button" OnClientClick="return ConfirmSave();"/>
</form>
</body>
</html>
<script>
function ConfirmSave()
{
var x
x= document.getElementById('<%=TextBox1.ClientID%>').value
return confirm('确定要删除['+ x +' ]吗?');
}
</script>
特别要注意的是, 在显示messagebox 的时候显示提取 textbox1 中的内容时必须要document.getElementById('<%=TextBox1.ClientID%>').value 取客户端的值,如果直接取textbox1.text 取到的时空值,因为现在的内容还没有到server 端。
完整的例子:
前台Page:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server"> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Save" runat="server" Text="Button" OnClientClick="return ConfirmSave();"/>
</form>
</body>
</html>
<script>
function ConfirmSave()
{
var x
x= document.getElementById('<%=TextBox1.ClientID%>').value
return confirm('确定要删除['+ x +' ]吗?');
}
</script>
后台code:
Partial Class test
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub Save_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Save.Click
Me.Response.Write("你点了确定保存,现在继续执行Click 里面的内容..")
End Sub
End Class
分享到:
相关推荐
由于ASP.NET中没有象C/S中的MessabeBox类,故自定义一个这样的类来实现提示消息,消息对话框等功能。 调用例子: 引入命名空间 using MDAN.Common; <br>第一种: MessageBox.Show(this, "删除成功!")...
60. Renamed Coolite.Ext.Web.MessageBox.Config to Ext.Net.MessageBoxConfig 61. XmlReader: rename TotalRecords to the TotalProperty 62. Added new .After property to DirectEvents. The .After ...
Application.MessageBox 详解 ..doc
这是一个自己编写的MessageBox,非常好用
/// /// 自定义信息对话框 /// public class MessageBox { /// /// 定义一个web页面,用来显示用户自定错误提示信息 /// System.Web.UI.Page p; /// /// 实例时,参数为:this 如:MessageBox MB=new ...
MFC 自定义 MessageBox.zipMFC 自定义 MessageBox.zipMFC 自定义 MessageBox.zipMFC 自定义 MessageBox.zipMFC 自定义 MessageBox.zipMFC 自定义 MessageBox.zipMFC 自定义 MessageBox.zipMFC 自定义 MessageBox....
windows开发使用到的MessageBox显示英文或者其他语言方法。
在 ASP.NET 2.0 中创建 Web 应用程序主题 ASP.NET 2.0 中的数据访问 ASP.NET 2.0:弃用 DataGrid 吧,有新的网格控件了! 将 ASP.NET 2.0 应用程序服务配置为使用 SQL Server 2000 或 SQL Server 2005 ASP.NET 2.0 ...
,这是一个ASP.NET WEB测试代码,数据库为access,把Access中的内容导出到Excel文件中,并保持数据格式不变,测试时请在ASP.NET3.5环境以上进行,数据库文件路径请修改Web.config文件。使用说明: 1.先将本目录下...
计算机软件-编程源码-messagebox无敌.zip
MessageBox.Show()共有21中重载方法。现将其常见用法总结如下: 1.MessageBox.Show("Hello~~~~"); 最简单的,只显示提示信息。 2.MessageBox.Show("There are something wrong!","ERROR"); 可以给消息框加上...
改变Messagebox按钮的文字[改变Messagebox按钮的文字]-精品源代码
用钩子函数实现的自定义MessageBox,可以修改按钮的文字等属性
MessageBox类.添加到ASP.NET项目中.直接通过MessageBox.Show()可实现页面弹框.像C/S程序一样简单易用.
// UnSafeSwap.cs // 不安全代码示例 // 编译命令:csc /unsafe UnSafeSwap.cs using System; class Program { public static void Main() { int a = 2;... Console.WriteLine("交换前:a = {0}, b = {1}", a, b);...
中文的,解释的很全面,简单明了,一看就懂。不信下下来试试。
您无法修改javascript的确认框。 看一下jQuery选项。http://projectshadowlight.org/jquery-easy-confirm-dialog/ [^]
用qt自定义的messagebox,共有7种,详细的使用效果见https://blog.csdn.net/qq_37603131/article/details/113363386
public static void MessageBox(System.Web.UI.Page page, string msg) { page.ClientScript.RegisterStartupScript(typeof(string), "message", "$(document).ready(function() { var para = { mode: '...