【问题标题】:ASP.Net Ajax client side script, accessing sourceASP.Net Ajax 客户端脚本,访问源代码
【发布时间】:2009-09-17 08:34:13
【问题描述】:

我在很多 asp.net ajax 客户端脚本示例中看到了以下内容:

function fHelloWorld(source, eventArgs)
{

}

如果我在源上运行警报,它将作为对象返回。我可以使用它来访问所谓的功能吗?如果是这样怎么办?我试过像

source.id;

没有运气

【问题讨论】:

    标签: asp.net ajax


    【解决方案1】:

    我能提供的最好建议是,给定一个对象,枚举属性并将它们写出来,包括它们在页面中的值。然后检查属性值,肯定会发现是否存在这样的属性。您还可以使用FirebugFiddler2 或其他许多工具来检查对象。

    这是一个例子

    function pageLoad(sender, args) {
    
    // add function to the PageRequestManager to be executed on async postback initialize
    var prm = Sys.WebForms.PageRequestManager.getInstance();
          prm.add_initializeRequest(InitializeRequest);   
    }
    
    
    function InitializeRequest(sender, args) {
        // Display loader gif when async postback initialized by element_in_question
        if(args._postBackElement.id === 'id_of_element_in_question' {              
            $get('ajax-loader').style.display = 'inline';
        }         
    }
    

    【讨论】:

      【解决方案2】:

      在您的函数中使用 Firefox 和 Firebug、set a breakpoint 运行页面,并以交互方式检查 source 对象。

      您也可以使用console.log显示对象以获得对象检查超链接:

      function fHelloWorld(source, eventArgs)
      {
        console.log("%o", source);
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-09-18
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多