简体   繁体   English

IIS7中未触发JavaScript onchange事件

[英]JavaScript onchange event is not firing in IIS7

Source Code: 源代码:

<ajaxToolkit:TabContainer ID="tbMBQOutputs" runat="server" Width="100%" Height="720px">
    <ajaxToolkit:TabPanel ID="tbDashboard" runat="server" Height="100%" ToolTip="Dashboard">
    <HeaderTemplate>Dashboard</HeaderTemplate>
    <ContentTemplate>
        <asp:UpdatePanel ID="upDashboard" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
           <table bgcolor="#E6E6FA" align="center" border="0" cellpadding="0" cellspacing="0" style="width: 100%; height: 99%; border: solid 1px black; margin-left: 1px; margin-right: 1px;">
           <tr>
               <td>
                    <asp:Panel ID="pnlDashboard_DC" runat="server" GroupingText="Dashboard">
                    <table align="center" border="0" cellpadding="0" cellspacing="0" style="width: 100%; height: 99%; border: solid 1px black; margin-left: 1px; margin-right: 1px;">
                    <tr>
                        <td align="center">
                             <asp:Label ID="lblReportCycle_DB" runat="server" Text="Report Cycle"></asp:Label>&emsp;   
                             <asp:DropDownList ID="ddlReportCycle_DB" runat="server" AutoPostBack="true" Width="140px" CssClass="tb2" OnSelectedIndexChanged="ddlReportCycle_DB_SelectedIndexChanged" ></asp:DropDownList>
                          </td>
                     </tr>                         
                     <tr>
                          <td align="center">
                               <asp:Label ID="lblMsgDashBoard_DB" runat="server" Font-Bold="true" ForeColor="Green"></asp:Label>
                          </td>
                      </tr>
                 </table>
                 </asp:Panel>
            </td>
            </tr>
            </table>
            </ContentTemplate>
       </asp:UpdatePanel>
       </ContentTemplate>
       </ajaxToolkit:TabPanel>
   </ajaxToolkit:TabContainer>

JavaScript: JavaScript:

  <script type="text/javascript">
         function ProgressImage_DashBoard() {
        $('#<%=lblMsgDashBoard_DB.ClientID%>').html("Processing.... Please wait...!!!");
    }
  </script>

Code Behind File: 文件后面的代码:

  protected void Page_Load(object sender, EventArgs e)
  {
       ddlReportCycle_DB.Attributes.Add("onchange", "ProgressImage_DashBoard();");
  }

This coding is working fine in my system. 该编码在我的系统中运行良好。 But when I publish the code in IIS 7, the dropdownlist change event is not at all firing. 但是,当我在IIS 7中发布代码时,下拉列表更改事件根本没有触发。

But when I comment the code the below code in Page Load Event, 但是,当我在页面加载事件中注释以下代码时,

//ddlReportCycle_DB.Attributes.Add("onchange", "ProgressImage_DashBoard();");

In IIS 7, the dropdownlist change event is working. 在IIS 7中,下拉列表更改事件正在运行。 I need to show the label message during dropdownlist change event. 我需要在dropdownlist更改事件期间显示标签消息。 ie Processing. 即处理。 Why this code is not working in IIS 7? 为什么此代码在IIS 7中不起作用?

Apparantly this is caused by IE configuration for JavaScript. 显然,这是由JavaScript的IE配置引起的。 In IIE7 the default configuration is "disable JavaScript" for certain kind of safety reasons, so you have to enable it. 在IIE7中,出于某种安全原因,默认配置为“禁用JavaScript”,因此必须启用它。

https://forums.iis.net/t/1150606.aspx https://forums.iis.net/t/1150606.aspx

I tried this, it is working.. 我试过了,它正在工作..

Source Code: 源代码:

  <asp:Label ID="lblMsgDashBoard_DB" runat="server" Font-Bold="true" ForeColor="Green"></asp:Label>
  <asp:DropDownList ID="ddlReportCycle_DB" runat="server" AutoPostBack="true" Width="140px" CssClass="tb2" OnSelectedIndexChanged="ddlReportCycle_DB_SelectedIndexChanged" onchange="ShowMsg(this);"></asp:DropDownList>

JavaScript: JavaScript:

  function ShowMsg(ddl) {            
        var lblMsg = document.getElementById("<%=lblMsgDashBoard_DB.ClientID %>");
        $(lblMsg).html("Processing.... Please wait...!!!");
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM