我有以下代码在开发机器上工作正常。但是,当我将它部署到IIS时,the .click()
不会触发。asp.net javascript .click()事件不在服务器上触发
我有下拉框,当选择一个状态,我添加以下代码打开了一个RadWindow
if (ddlStatusID.SelectedValue.ToString() == "2") btnUpdateStatus.Attributes.Add("onclick", "return OpenWindow2('" + ResolveUrl("~/Request/AddBillableTime.aspx? RequestId=" + RequestId.ToString()) + "','650','320');"); else btnUpdateStatus.Attributes.Add("onclick", "");
在弹出的页面中,当一个按钮,我的用户点击加做以下
ClientScript.RegisterStartupScript(this.GetType(), "CloseWindow", "ClosePopup();", true);
这是ClosePopup的JavaScript。
function ClosePopup() {
//debugger;
alert('This is before closing the window');
var oWindow = GetRadWindow();
oWindow.argument = null;
oWindow.close();
alert('This is after closing the window');
oWindow.BrowserWindow.ButtonClick();
}
在主窗口中,我已经以下JavaScript,这是在上述的javascript的最后一行调用。
function ButtonClick() { //debugger; alert('This is before button click!'); var btnUpdateStatus = document.getElementById('ctl00_ContentPlaceHolder1_btnUpdateStatus'); alert('This is getting the button!'); btnUpdateStatus.setAttribute("onclick", ""); alert('This is setting the button!'); btnUpdateStatus.click(); alert('This is after clicking the button!');
}
我已经使用了警报检查多远执行JavaScript函数。
当我使用Visual Studio运行它时,以及当我在本地IIS服务器上托管它时,整个功能工作正常。但是,当我将它部署到服务器时,click()事件停止发射。
请让我知道如果代码中有任何错误。
嗨我已经按照你的建议,但它会给出以下错误。 Controls集合不能被修改,因为控件包含代码块(即<% ... %>)。 但我用#替换了=,可以摆脱错误。但部署后仍存在问题。 我使用了一些警报来确定代码被执行到什么地方,并发现整个Javascript被执行。但是,不会调用按钮点击方法。 请帮忙。 – 2012-09-03 07:22:43