Reputation: 2140
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!
Upvotes: 0
Views: 2175
Reputation: 1159
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>
Upvotes: 3