javascript - 在自动回发下拉列表后刷新 javascript 代码

标签 javascript asp.net vb.net datepicker

我有一个表格和一个公司下拉列表:

                          <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                                 <ContentTemplate>
                                     <%--DataSourceID="sdsEmpresaTarea"--%>
                                     <asp:DropDownList ID="ddlEmpresaTarea" runat="server"
                                         DataValueField="IdEmpresa" DataTextField="Empresa" 
                                         AutoPostBack="true" ViewStateMode="Enabled">
                                     </asp:DropDownList>
                                 </ContentTemplate>
                          </asp:UpdatePanel>

第二个下拉列表显示公司下拉列表中所选公司的联系人:

<asp:DropDownList ID="ddlContactoTarea" runat="server"
   DataValueField="IdContacto" DataTextField="Nombre" ViewStateMode="Enabled">
</asp:DropDownList>

一个日期选择器文本框:

  <asp:TextBox ID="txtDate" runat="server" Text="" CssClass="datepicker" MaxLength="10" ViewStateMode="Enabled"/>
      <asp:RequiredFieldValidator ID="rfvDate" runat="server" 
          ErrorMessage="Date required"
          ControlToValidate="txtDate"  Display="Dynamic"> 
      </asp:RequiredFieldValidator>

The problem is when I expand the dropdownlist and I select an option, the dropdownlist execute the autopostback and in code I have a method to search the contacts for the company selected in the dropdownlist for companies, and then the datepicker doesn't work. I have to stress that when I charge the page, the datepicker works good, but then when I select a company in the dropdownlist, then datepicker doesn't work, and I think that this happened because the javascript code is not refresh after the autopostback.

How can I refresh the javascript code each time the dropdownlist for companies is selected?

最佳答案

Sys.Application.add_load 中发布您的 Javascript 代码

$(function(){
            Sys.Application.add_load(function () { 
           // your Java script Code here
                   });

            });

关于javascript - 在自动回发下拉列表后刷新 javascript 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32882613/

相关文章:

vb.net - 我如何将参数传递给后台工作人员?

javascript - 如何使用 jQuery 从子类中获取值

javascript - 函数的 Canvas 部分无法运行?

javascript - 根据回调函数对对象进行分组

javascript - Onclick按钮超时javascript

javascript - 顶级脚本 block 执行了两次?

VB.Net 形式的非共享方法被引用就像它们被共享一样?

c# - 简单插入,更新到 SQL Server

html - 如何使用 HTML 菜单从一个页面导航到另一个页面?

mysql - 在 VB 中从 MySQL 数据库获取第一个条目