asp.net在用ajax的时候如何弹出对话框
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<asp:updatepanel ID="UP" runat="server">
<ContentTemplate>
<asp:Button runat="server" Text="Button" onclick="Unnamed2_Click" />
</ContentTemplate>
</asp:updatepanel>
</div>
</form>
ASP.NET2.0中AJAX使用新的Manager 类来管理,而不兼容原来的 ClientManager 类 ,所以用response.write("<script>alert('提示:点我了!')</script>")和
this.Client.RegisterClientBlock(this.GetType(), "name", "<>alert('提示:点我了!');</>", true);
Page.Client.RegisterClientBlock(this.GetType(), "name", "<>alert('提示:点我了!);</>", true);
这些方法都是无效的.
可以用以下方法写代码实现
ScriptManager.RegisterStartupScript(UP, UP.GetType(), "", "alert('点我了');", true);
这样就可以实现了!
//UP是updatepanel 的ID
转自http://www.csharp360.com/bbs/viewthread.php?tid=233&extra=
相关文档:
1. 注册js函数
String scriptString = "<script language=JavaScript>function doClick(){";
scriptString += "for(var index=0;index<myArray.length;index++)";
scriptString += "alert(myArray[index]);}<";
scriptString += "/" + "script>";
ClientScript.RegisterStartupScript(typeof(WebForm2) ......
页面代码:
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManage ......
在《Pragmatic Ajax A Web 2.0 Primer 》中偶然看到对readyStae状态的介绍,感觉这个介绍很实在,摘译如下:
0: (Uninitialized) the send( ) method has not yet been invoked.
1: (Loading) the send( ) method has been invoked, request in progress.
2: (Loaded) the send( ) method has completed, entire respons ......
经常需要在数据库与Execl之间互导数据。net时代,ADO.NET可以使用使用Microsoft.Jet.OleDb访问访问Excel,网上已经有很多类似的资源,最典型也是最简单的可能如下:(asp.net环境)
// 连接字符串
......