I am using a combobox on my website and when the SelectedIndexChanged
event triggers, the page refreshes. I know you can prevent the page refresh with an UpdatePanel
but I need another solution to prevent a page refresh.
Do you guys know any other solutions? Thanks in advance!
By your description in comments I think you want this. I´m using Jquery. This is a way to set value in textbox without to do postback. Remember to set AutoPostback=false in your DropDownList
<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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.