向大家请教ajax技术,客户端如何执行服务器事件,谢谢 客户端如何执行服务器事件谢谢,最好给个例子 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //后台 [WebMethod] [ScriptMethod] public static string CallCheckData(string value) { return "this is xiao Q"; }前台function aa(){PageMethods.CallCheckData(para1,completeConsignee); }function completeConsignee(){ //do something } 看这个吧,比较通俗http://topic.csdn.net/u/20080612/18/13fb478c-8cc3-48d6-a679-bc3e396751ed.html 看楼主打算用什么方式的ajax技术了用微软自带的ajax框架是最简单的了 我打算比如gridview的选择列表,在选择的时候,触发计算gridview某数值列选中值的总和,谢谢,不只是是否可以实现 可以实现,这个不用ajax也能做到吧...在脚本里写就可以了 建议lz去迅雷下些ajax视频看看我就是这样学过来的。那些视频里有些是关于Ajax控件的,有很少是直接写代码的而lz需要看的就是直接写代码的! 至于直接写代码就是要写两个文件:JS文件和ashx文件(一般处理函数)执行方式是客户端条用js文件,js文件里调用一般处理函数,一般处理函数里再调用你写的方法!这样就能执行服务器端事件了! <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!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>无标题页</title> <script language="javascript" type="text/javascript">// <!CDATA[function btnInvoke_onclick() { var theName = $get("tbName").value; PageMethods.SayHelloFromPage(theName, onSayHelloSucceeded);}function onSayHelloSucceeded(result) { $get("result").innerHTML = result;}// ]]> </script></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="sm" EnablePageMethods="true" runat="server" /> <input id="tbName" type="text" /> <input id="btnInvoke" type="button" value="Say Hello" onclick="return btnInvoke_onclick()" /> <div id="result"> </div> </form></body></html>using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Web.Services;public partial class _Default : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { } [WebMethod] public static string SayHelloFromPage(string name) { return string.Format("Hello {0}!", name); }} 看样子学的东西还很多,引用 5 楼 amandag 的回复:引用楼主 yegucheng 的帖子: 客户端如何执行服务器事件 谢谢,最好给个例子 看楼主打算用什么方式的ajax技术了 用微软自带的ajax框架是最简单的了 ------------------------------------哪位能讲讲如何用微软自带的ajax框架,如何简单,谢谢,分不够再加 谢谢各位朋友,我是不考虑性能搞定了这个问题,用ajax控件,发现这玩意功能还是蛮强大的 .net中日期比较格式问题 sql winform如何动态在richtextbox里面添加表格 如何让最后3个选项的背景为红色?? 如何安装ASP.NET AJAX 控件工具包??? 100分求助,安装VS2005遇到问题了,安装VS2005遇到问题了,安装VS2005遇到问题了 页面登分数值的控制 求教页面框架设计~类似vs05操作界面中右边-解决方案-的对话框的设置! 页面提交问题 一个很简单的问题 在Web里嵌入一个WinForm控件后,该控件是读取哪个配置文件? 关于get和set在webservice里怎么用?
[WebMethod]
[ScriptMethod]
public static string CallCheckData(string value)
{
return "this is xiao Q";
}前台
function aa()
{
PageMethods.CallCheckData(para1,completeConsignee);
}
function completeConsignee()
{
//do something
}
http://topic.csdn.net/u/20080612/18/13fb478c-8cc3-48d6-a679-bc3e396751ed.html
看楼主打算用什么方式的ajax技术了用微软自带的ajax框架是最简单的了
在脚本里写就可以了
我就是这样学过来的。
那些视频里有些是关于Ajax控件的,有很少是直接写代码的
而lz需要看的就是直接写代码的!
JS文件和ashx文件(一般处理函数)
执行方式是客户端条用js文件,js文件里调用一般处理函数,一般处理函数里再调用你写的方法!
这样就能执行服务器端事件了!
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title> <script language="javascript" type="text/javascript">
// <!CDATA[function btnInvoke_onclick() {
var theName = $get("tbName").value;
PageMethods.SayHelloFromPage(theName, onSayHelloSucceeded);
}function onSayHelloSucceeded(result) {
$get("result").innerHTML = result;
}// ]]>
</script></head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="sm" EnablePageMethods="true" runat="server" />
<input id="tbName" type="text" />
<input id="btnInvoke" type="button" value="Say Hello" onclick="return btnInvoke_onclick()" />
<div id="result">
</div>
</form>
</body>
</html>using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Services;public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
} [WebMethod]
public static string SayHelloFromPage(string name)
{
return string.Format("Hello {0}!", name);
}
}
引用 5 楼 amandag 的回复:
引用楼主 yegucheng 的帖子:
客户端如何执行服务器事件
谢谢,最好给个例子
看楼主打算用什么方式的ajax技术了 用微软自带的ajax框架是最简单的了
------------------------------------
哪位能讲讲如何用微软自带的ajax框架,如何简单,谢谢,
分不够再加