代码之家  ›  专栏  ›  技术社区  ›  Echilon Mafarnakus

ASP.NET GridView和UpdatePanel

  •  1
  • Echilon Mafarnakus  · 技术社区  · 15 年前

    我有一个 GridView ,内部 UserControl ,在 UpdatePanel

    有一个 Button 网格视图 PostBack . 结果是: 用户点击 按钮 RowCommand 火灾->在上引发自定义事件 用户控件 -&燃气轮机;页检测到此情况并更改 MultiView 更新面板 .

    问题是,页面异步回传,页面标题更改,但操作需要一个完整的 回发 不要因为

    将按钮注册为 回发 我使用的触发器:

    ImageButton btnResults = e.Row.FindControl("btnResults") as ImageButton;
    ScriptManager scrCurrent = ScriptManager.GetCurrent(this.Page);
    if (btnResults != null && scrCurrent != null) {
        scrCurrent.RegisterPostBackControl(btnResults);
    }
    

    1 回复  |  直到 7 年前
        1
  •  1
  •   Echilon Mafarnakus    15 年前

    最终的解决方案是按原样使用上述代码,但使用RowCreated事件而不是RowDataBound。显然,ASP.NET的一个怪癖是,有时事件顺序令人惊讶,而且看起来不可预测。出于同样的原因,我发现最好尽可能晚地注册JavaScript,所以我通常使用SaveStateComplete事件。