客户端如何执行服务器事件
谢谢,最好给个例子

解决方案 »

  1.   

    //后台
     [WebMethod]
            [ScriptMethod]
            public static string CallCheckData(string value)
            {
                return "this is xiao Q";
            }前台
    function aa()
    {
    PageMethods.CallCheckData(para1,completeConsignee);  
    }
    function completeConsignee()
    {
       //do something 
    }
      

  2.   

    看这个吧,比较通俗
    http://topic.csdn.net/u/20080612/18/13fb478c-8cc3-48d6-a679-bc3e396751ed.html
      

  3.   


    看楼主打算用什么方式的ajax技术了用微软自带的ajax框架是最简单的了
      

  4.   

    我打算比如gridview的选择列表,在选择的时候,触发计算gridview某数值列选中值的总和,谢谢,不只是是否可以实现
      

  5.   

    可以实现,这个不用ajax也能做到吧...
    在脚本里写就可以了
      

  6.   

    建议lz去迅雷下些ajax视频看看
    我就是这样学过来的。
    那些视频里有些是关于Ajax控件的,有很少是直接写代码的
    而lz需要看的就是直接写代码的!
      

  7.   

    至于直接写代码就是要写两个文件:
    JS文件和ashx文件(一般处理函数)
    执行方式是客户端条用js文件,js文件里调用一般处理函数,一般处理函数里再调用你写的方法!
    这样就能执行服务器端事件了!
      

  8.   

    <%@ 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);
        }
    }
      

  9.   

    看样子学的东西还很多,
    引用 5 楼 amandag 的回复:
    引用楼主 yegucheng 的帖子: 
    客户端如何执行服务器事件 
    谢谢,最好给个例子 
    看楼主打算用什么方式的ajax技术了 用微软自带的ajax框架是最简单的了 
    ------------------------------------
    哪位能讲讲如何用微软自带的ajax框架,如何简单,谢谢,
    分不够再加
      

  10.   

    谢谢各位朋友,我是不考虑性能搞定了这个问题,用ajax控件,发现这玩意功能还是蛮强大的