Asp.net asp:DropDownList在选择输入时提交页面
我有一个asp.net页面,其中有一个带有默认按钮的面板、更新面板和更新面板内的dropdownlist。当我用向上/向下键选择一个项目并按enter键选择该项目时,填写表单时,表单正在提交。我怎样才能解决这个问题 编辑 一些代码:Asp.net asp:DropDownList在选择输入时提交页面,asp.net,forms,drop-down-menu,submit,form-submit,Asp.net,Forms,Drop Down Menu,Submit,Form Submit,我有一个asp.net页面,其中有一个带有默认按钮的面板、更新面板和更新面板内的dropdownlist。当我用向上/向下键选择一个项目并按enter键选择该项目时,填写表单时,表单正在提交。我怎样才能解决这个问题 编辑 一些代码: <asp:SqlDataSource ID="sdsCountries" runat="server" ConnectionString="cs" SelectCommand="SELECT CountryID, Title FROM Countries"/&
<asp:SqlDataSource ID="sdsCountries" runat="server" ConnectionString="cs"
SelectCommand="SELECT CountryID, Title FROM Countries"/>
<asp:DropDownList ID="ddlCountries" runat="server" DataSourceID="sdsCountries"
DataValueField="CountryID" DataTextField="Title" AutoPostBack="True"
OnSelectedIndexChanged="ddlCountries_SelectedIndexChanged"/>
<asp:UpdatePanel ID="upState" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:SqlDataSource ID="sdsStates" runat="server" ConnectionString="cs"
SelectCommand="SELECT StateID, Title FROM States WHERE CountryID=@CountryID">
<SelectParameters><asp:ControlParameter Name="CountryID"
ControlID="ddlCountries" PropertyName="SelectedValue" DefaultValue="1"/>
</SelectParameters>
</asp:SqlDataSource>
<asp:DropDownList ID="ddlStates" runat="server" DataSourceID="sdsStates"
DataValueField="StateID" DataTextField="Title"/>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlCountries"
EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
在下拉列表中,确保属性“AutoPostBack”未设置为“true”
编辑:看到你的评论。我不擅长使用ASP.Net更新面板,因为我通常使用jquery处理ajax内容,但我相信您必须将您的DDL国家/地区下拉列表放在它自己的更新面板中,或者将其移动到状态更新面板,并在更新面板上将ChildrenAsTriggers属性设置为true。将AutoPostBack设置为false但我需要启用它,因为还有一个相关数据的下拉列表。例如,国家>州。更改ddlStates时,ddlStates将填充相关项。不起作用。到目前为止,最好的解决方案是删除面板和默认buton