避免在选择没有更新面板的交换组合框后刷新页面

本文关键字:组合 交换 刷新 选择 更新 | 更新日期: 2023-09-27 18:05:51

我在我的网站上使用一个组合框,当SelectedIndexChanged事件触发时,页面刷新。我知道你可以用UpdatePanel来防止页面刷新,但我需要另一个解决方案来防止页面刷新。

你们知道其他的解决方法吗?提前感谢!

避免在选择没有更新面板的交换组合框后刷新页面

根据你在评论中的描述,我认为你想要这个。我正在使用Jquery。这是一种在文本框中设置值而不需要回发的方法。记住在下拉列表中设置AutoPostback=false

<form id="form1" runat="server">
<asp:DropDownList ID="DropDownList1" runat="server">
    <asp:ListItem>Item 1</asp:ListItem>
    <asp:ListItem>Item 2</asp:ListItem>
    <asp:ListItem>Item 3</asp:ListItem>
    <asp:ListItem>Item 4</asp:ListItem>
</asp:DropDownList>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</form>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
<script>
    var slcLocationSelect = false;
    var slcSpecialtySelect = false;
    var slcGenderSelect = false;
    $(document).ready(function () {
        $("#<%=DropDownList1.ClientID %>").change(function () {
            $("#<%=TextBox1.ClientID %>").val($("#<%=DropDownList1.ClientID %>").val())
        });
    });
</script>