asp.net如何在后台代码中执行js

2024-11-17 17:26:03
推荐回答(3个)
回答1:

把Page_load()事件里面的btn.Attributes.Add("onclick", "opendialog('ShowDialog.aspx')");去掉
ClientScript.RegisterStartupScript(this.GetType(), "", "", true);
修改为:
ClientScript.RegisterStartupScript(this.GetType(), "aa", "opendialog(ShowDialog.aspx)
", true);试试...

回答2:

把page_load里面的btn.Attributes.Add("onclick", "opendialog('ShowDialog.aspx')");
去掉,在响应事件里面直接写
this.ClientScript.RegisterStartupScript(this.GetType(),"1","");试试~~

回答3:

直接在HTML里面就可以的