• 谁能告诉我这两个方法的区别?


    ASP.NET 中 Page 对象有几个方法用于得到客户端 PostBack 的 javascript 代码,其中有下面两个:
    GetPostBackEventReference 和 GetPostBackClientEvent

    翻看 msdn 里的解释没弄明白为什么这里要安排两个方法,唯一的区别就是 GetPostBackEventReference 有两个重载形式。于是我用 Reflector 看了一下,代码分别如下:

    System.Web.UI.Page.GetPostBackEventReference(Control, String) : String

    [EditorBrowsable(EditorBrowsableState.Advanced)]
    public string GetPostBackEventReference(Control control, string argument)
    {
          
    string[] textArray1;
          
    this.RegisterPostBackScript();
          
    if (this._inOnFormRender)
          
    {
                textArray1 
    = new string[5"__doPostBack('", control.UniqueIDWithDollars, "','", Util.QuoteJScriptString(argument), "')" } ;
                
    return string.Concat(textArray1);
          }

          textArray1 
    = new string[5"__doPostBack('", control.UniqueID, "','", Util.QuoteJScriptString(argument), "')" } ;
          
    return string.Concat(textArray1);
    }

    System.Web.UI.Page.GetPostBackClientEvent(Control, String) : String

    [EditorBrowsable(EditorBrowsableState.Advanced)]
    public string GetPostBackClientEvent(Control control, string argument)
    {
          
    return this.GetPostBackEventReference(control, argument);
    }

    可以看到,第二个方法仅仅是简单的调用了上面方法的基本形式而已,那么为什么还需要这个 GetPostBackClientEvent 呢? 哪位能解释一下。
  • 相关阅读:
    cf-779E (拆位)
    石子游戏 (SG函数)
    [POI2017] Flappy Bird (思维题)
    Alice and Bob (SG函数)
    Red is good (DP)
    CodeVS-1669 (背包问题)
    GalaxyOJ-468 (LCA)
    BZOJ-1191 (二分图匹配)
    Reinforcement Learning 笔记(4)
    Reinforcement Learning 笔记(3)
  • 原文地址:https://www.cnblogs.com/RChen/p/104757.html
Copyright © 2020-2023  润新知