首页 > 解决方案 > 带有更新面板的内容页面未运行 javascript?

问题描述

我有一个 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"

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

标签: javascriptc#asp.netupdatepanel

解决方案


我终于解决了

    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

推荐阅读