使用updatepanel的内容页面未运行javascript?

时间:2019-04-13 09:44:18

标签: javascript c# asp.net updatepanel

我有一个gridview,bootstrap模式,该模式位于引用主页面的内容页面的更新面板中。

gridview中有3列和一个linkbutton。

当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"

如何弹出弹出模式?一切都在updatepanel中。

1 个答案:

答案 0 :(得分:0)

我终于解决了

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

页面上的事件。

感谢此链接。

import json
from pprint import pprint
a=["/",
"/page1.html",
"/cocktails/receipe/page1.html",
"/cocktails/receipe/page2.html",
"/cocktails/page3.html",
"/article/magazine",
"/article/mood/page1.html"]

def create(path,dictionaryandarray):
    #print(path[0],dictionary)
    if not path:
        return
    for ele in dictionaryandarray:
        if 'name' in ele and ele['name'] == path[0]:
            ele.setdefault('children',[])
            if (path[1:]):
                create(path[1:],ele['children'])
            return
    newvalue={'name':path[0]}
    if (path[1:]):
        newvalue['children']=[]

    dictionaryandarray.append(newvalue)
    if (path[1:]):
        create(path[1:], dictionaryandarray[-1]['children'])
d = []
for i in a:
    parts = [j for j in i.split('/') if j != '']
    create(parts ,d)

data={'name':'/','children':d}
data=json.dumps(data, indent=4, sort_keys=False)
# pprint(data)
print(data)