我们已经使用CascadingDropDown来填充下拉列表。发生回发时,将自动触发下拉菜单的客户端更改事件。这是Firefox 65的特定行为。在chrome中,仅当用户从下拉菜单中手动选择值时,才会触发此事件。
有人可以帮助我解决此问题吗?
这是代码。
protected void btn1_Click(object sender, EventArgs e)
{
cdlCountries.SelectedValue = "2";
cdlStates.SelectedValue = "4";
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CS.aspx.cs" Inherits="CS" EnableEventValidation="false" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<title></title>
<style type="text/css">
body
{
font-family: Arial;
font-size: 10pt;
}
</style>
<script type="text/javascript">
$(document).ready(function () {
$("#<%=ddlCities.ClientID%>").change(function () {
alert("");
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</cc1:ToolkitScriptManager>
<table>
<tr>
<td style="width: 80px">
Country:
</td>
<td>
<asp:DropDownList ID="ddlCountries" runat="server" Width="150">
</asp:DropDownList>
<cc1:CascadingDropDown ID="cdlCountries" TargetControlID="ddlCountries" PromptText="Select Country"
PromptValue="" ServicePath="ServiceCS.asmx" ServiceMethod="GetCountries" runat="server"
Category="CountryId" LoadingText="Loading..." EnableAtLoading="false" />
<asp:Button ID ="btn1" runat="server" OnClick="btn1_Click" Text="Submit" />
</td>
</tr>
<tr>
<td>
State:
</td>
<td>
<asp:DropDownList ID="ddlStates" runat="server" Width="150">
</asp:DropDownList>
<cc1:CascadingDropDown ID="cdlStates" TargetControlID="ddlStates" PromptText="Select State"
PromptValue="" ServicePath="ServiceCS.asmx" ServiceMethod="GetStates" runat="server"
Category="StateId" ParentControlID="ddlCountries" LoadingText="Loading..." EnableAtLoading="false"/>
</td>
</tr>
<tr>
<td>
City:
</td>
<td>
<asp:DropDownList ID="ddlCities" runat="server" Width="150">
</asp:DropDownList>
<cc1:CascadingDropDown ID="cdlCities" TargetControlID="ddlCities" PromptText="Select City"
ServicePath="ServiceCS.asmx" ServiceMethod="GetCities" runat="server"
Category="CityId" ParentControlID="ddlStates" />
</td>
</tr>
</table>
</form>
</body>
</html>
在Firefox中打开它>>单击“提交”按钮>>它调用不应更改的城市更改事件。