使用updatePanel从服务器调用方法
来源:互联网 发布:淘宝客教学视频 编辑:程序博客网 时间:2024/05/16 15:27
<html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>UpdatePanelDemo</title> <style> .PleaseWait { height:200px; width:500px; background-image:url(../css/img/pleasewait.gif); background-repeat:initial; padding-left:40px; line-height :32px; } </style> <script src="../Resource/jquery-1.11.3.js"></script> <script> function sayhello() { var va = $("#TextBox1").val(); /*确保ScriptManager已经引用了Path,这样就可以直接使用NameService名字.后面intelLisense会直接匹配出相应的方法. 注意回调函数,它会默认接收回来的值,并以此参数执行方法. 注意 1.回调函数要注入参数. 2.传递回调函数不需要引入参数. */ NameService.HelloWorld(va, callback); }; function callback(str) { $("#Label1").text(str); }; </script> </head><body> <form id="form1" runat="server"> <!--如果有主版页,且主版页里已经有了ScriptManager,就应该使用ScriptManagerProxy,它是与主版页的ScriptManager之间沟通的桥梁. 1.如果能在主版页中定义Path,那是最好.因为这样每个引用主版页的子页面都能够顺利地使用到这个Web服务.但坏处是如果有些起页面不使用Web服务,就会牺牲性能. 2.如果不能在主版页中定义另一个需要使用的Web服务.就可以使用代理(ScriptManagerProxy)来定义Web服务.--> <asp:ScriptManager runat="server"> <Services> <asp:ServiceReference Path="~/WebService/WebService/NameService.asmx" /> </Services> </asp:ScriptManager> <asp:UpdatePanel ID="updatePanel" runat="server"> <ContentTemplate> <div> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <input id="Button12" type="button" onclick="sayhello()" value="button" /> </div> </ContentTemplate> </asp:UpdatePanel> </form></body></html>
以下是asmx中的代码
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Services;/// <summary>/// NameService 的摘要说明/// </summary>[WebService(Namespace = "http://asp.service.study/")][WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。 [System.Web.Script.Services.ScriptService]public class NameService : System.Web.Services.WebService { public NameService () { //如果使用设计的组件,请取消注释以下行 //InitializeComponent(); } [WebMethod] public string HelloWorld(String Name) { return String.Format("Hello {0}",Name); }}
0 0
- 使用updatePanel从服务器调用方法
- GridView导出Excel使用UpdatePanel导致“无法分析从服务器收到的消息”解决方法.
- ASP.NET调用UpdatePanel的Update()方法
- 使用UpdatePanel,在后台调用alert
- updatepanel 中使用JS alert方法
- UpdatePanel中使用FileUpload的变通方法
- 使用UpdatePanel时触发JS的方法
- UpDatePanel使用
- c#调用javascript的方法,有Updatepanel的情况
- UpdatePanel中内容异步加载后,调用JS脚本方法
- asp.net 使用UpdatePanel 返回服务器处理后弹出对话框
- asp.net 使用UpdatePanel 返回服务器处理后弹出对话框
- 使用UpdatePanel,在后台调用alert 的解决方法,
- UpdatePanel内调用javascript
- updatepanel里面使用使用弹出消息框的方法
- 在UpdatePanel使用脚本的方法(AJAX)
- 使用updatePanel控件出现sys...未定义问题的处理方法
- [转]updatepanel中使用alert弹出框方法
- 概率、随机数、随机数生成函数(面试题)
- HDU 1254:推箱子【DFS && BFS】
- 人见人爱A+B(2)
- Fragment详解之二——基本使用方法
- C#调用C++ DLL 中定义的函数
- 使用updatePanel从服务器调用方法
- Algorithm Intro - Radix Sort
- 创新实验室实习生每周工作总结【实习第十八周】
- 贝叶斯网的R实现( Bayesian networks in R)bnlearn(1)
- Python中安装以及配置easy_install
- [leetcode oj 217]Contains Duplicate
- 最有效地使用PNG之续篇:Zopfli优化
- Fragment详解之三——管理Fragment(1)
- 数据结构-赫夫曼树