我有一个表格和一个公司下拉列表:
<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/