代码之家  ›  专栏  ›  技术社区  ›  Cédric Boivin

从更新面板回发后调用javascript代码

  •  1
  • Cédric Boivin  · 技术社区  · 17 年前

    我读书 tis post

    但我的问题仍然存在。我尝试在回发时多次执行javascript,而该脚本仅在页面首次加载时执行。

    var xyz = DateTime.Now.ToLongTimeString();
      string script = @"BrokerCustomValue.value='" + CustomValueToBrokerListSerialized + "';alert('" + xyz + "');";
      ScriptManager.RegisterStartupScript(this, GetType(), Guid.NewGuid().ToString(), script, true);
    

    我需要精确地知道,我的回传事件是在点击更新面板中的链接按钮后触发的。如果我把我的链接直接放在页面上,它就起作用了

    1 回复  |  直到 9 年前
        1
  •  5
  •   Cédric Boivin    17 年前

    当您使用更新面板和whant注册脚本时,您需要使用updatePanel,并在registerstartupscript的参数中键入updatePanel

    这样地:

    var xyz = DateTime.Now.ToLongTimeString();
      string script = @"BrokerCustomValue.value='" + CustomValueToBrokerListSerialized + "';alert('" + xyz + "');";
      ScriptManager.RegisterStartupScript(_updPanel, _updPanel.GetType(), Guid.NewGuid().ToString(), script, true);