【问题标题】:Content Page with updatepanel not running javascript?带有更新面板的内容页面未运行 javascript?
【发布时间】:2019-09-03 22:57:46
【问题描述】:

我有一个 gridview、bootstrap 模式,它位于引用母版页的内容页面上的更新面板内。

我的网格视图中有 3 列和一个链接按钮。

当 Linkbutton 事件被触发时,javascript 应该被触发,但不是。

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(funct1);

我试过了,但在控制台中给了我 sys undefined 错误。

这是我的代码:

GridView -> 查看按钮 ->

var link = (Control)sender;
            GridViewRow row = (GridViewRow)link.NamingContainer;
            Label LiD = (Label)row.FindControl("LabelID");
            id = Convert.ToInt32(LiD.Text);
            Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "funct1()", true)            
             MandateDetailusingId(id);

也试过

//ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "MyFunction", "funct1()", true);

这是我的 javacript :=

function funct1() {
            $('#<%=MandateView.ClientID%>').modal("toggle");
            return false;
        } // div id="MandateView"

如何弹出模态?一切都在更新面板中。

【问题讨论】:

  • 查看stackoverflow.com/a/45442175/5836671,了解PageRequestManager的正确使用方法
  • @VDWWD 我试过你的方法,它会在加载时弹出模态。在按钮单击时,它会触发 sys undefined。

标签: javascript c# asp.net updatepanel


【解决方案1】:

我终于解决了

    Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(InitialiseSettings);

function InitialiseSettings(){
    // replace your DOM Loaded settings here. 
    // If you already have document.ready event, 
    // just take the function part and replace here. 
    // Not with document.ready 
    $(element).slideUp(1000, method, callback});

    $(element).slideUp({
                   duration: 1000, 
                   easing: method, 
                   complete: callback});
}

页面上的事件。

感谢这个链接。

https://stackoverflow.com/questions/14038684/execute-javascript-after-a-partial-postback-of-an-updatepanel

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-01
    • 1970-01-01
    • 2013-02-23
    • 2018-08-04
    相关资源
    最近更新 更多