想用.NET带的ScriptManager实现AJAX,不使用UpdatePanel。
页面实现了ICallBackEventHandler,对需要处理的事件进行处理。
但导致了一个问题,就是GetCallbackResul成员变得责任重大,紧耦合,低内聚。问一下,大家都是怎么做的?

解决方案 »

  1.   

    你要反编译一下Ajax.net然后找解决办法
      

  2.   

    与AJAX.NET实现的方式有关吗?个人认为没有什么关系。
      

  3.   

    有UpdatePanel为啥不用?干脆手写得了.
      

  4.   

    请下载doc并阅读,有详细说明,不过都是阴文的
    Calling Web Services from Client Script in ASP.NET AJAX
    Calling Web Service Methods
    // CallWebServiceMethods.js
    // This function calls the Web service method without 
    // passing the callback function. 
    function GetNoReturn()
    {
        Samples.AspNet.WebService.GetServerTime();
        alert("This method does not return a value.");
        
    }
    // This function calls the Web service method and 
    // passes the event callback function.  
    function GetTime()
    {
        Samples.AspNet.WebService.GetServerTime(
        OnSucceeded);
        
    }
    // This function calls the Web service method 
    // passing simple type parameters and the 
    // callback function  
    function Add(a,  b)
    {
        Samples.AspNet.WebService.Add(a, b, 
        OnSucceeded);
    }// This function calls the Web service method 
    // that returns an XmlDocument type.  
    function GetXmlDocument() 
    {
        Samples.AspNet.WebService.GetXmlDocument(
            OnSucceededWithContext, OnFailed,
            "XmlDocument")
    }// This function calls a Web service method that uses
    // GET to make the Web request.
    function MakeGetRequest() 
    {    Samples.AspNet.WebService.EchoStringAndDate(
            new Date("1/1/2007"), " Happy",
            OnSucceeded, 
            OnFailed, "HappyNewYear");}// This is the callback function invoked if the Web service
    // succeeded.
    // It accepts the result object, the user context, and the 
    // calling method name as parameters.
    function OnSucceededWithContext(result, userContext, methodName)
    {
        var output;
        
        // Page element to display feedback.
        var RsltElem = document.getElementById("ResultId");
        
        var readResult;
        if (userContext == "XmlDocument")
    {

        if (document.all) 
            readResult = 
            result.documentElement.firstChild.text;
    else
        // Firefox
       readResult =
            result.documentElement.firstChild.textContent;

         RsltElem.innerHTML = "XmlDocument content: " + readResult;
    }
        
    }// This is the callback function invoked if the Web service
    // succeeded.
    // It accepts the result object as a parameter.
    function OnSucceeded(result, eventArgs)
    {
        // Page element to display feedback.
        var RsltElem = document.getElementById("ResultId");
        RsltElem.innerHTML = result;
    }
    // This is the callback function invoked if the Web service
    // failed.
    // It accepts the error object as a parameter.
    function OnFailed(error)
    {
        // Display the error.    
        var RsltElem = 
            document.getElementById("ResultId");
        RsltElem.innerHTML = 
        "Service Error: " + error.get_message();
    }if (typeof(Sys) !== "undefined") Sys.Application.notifyScriptLoaded();
      

  5.   

    基本同意使用UppdatePanel,在没有形成系统的访问手段之前,应该使用最快捷的方式。
    当然,你可以使用自己封装的AJAX组件,这样就解决了这个问题。另外AJAXPRO提供的访问手段是通过HTTPMODULE做的,很方便,解决了LZ的问题,但大量的反射消耗更多的资源,未必是可取的。同样,直接请求一个URL对于一个页面来说,也是紧耦合,低内聚。所以,应该用UppdatePanel。