I want to use DropDownList selectedIndexChanged event without auto postback.
Can I?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Vikram AgrawalPosted Nov 7, 2014, 4:28 AM
Hi Tin Gyi,
There is many way to solve any problem and one of them is following
you can do it with the help of javascript also
you can write it on "onchange" event of DropDownList
see the following example......
HTML:
<asp:DropDownList ID="DropDownList1" runat="server" onchange="display('DropDownList1');">
<asp:ListItem Value="Item1">asp:ListItem>
<asp:ListItem Value="Item2">asp:ListItem>
<asp:ListItem Value="Item3">asp:ListItem>
<asp:ListItem Value="Item4">asp:ListItem>
<asp:ListItem Value="Item5">asp:ListItem>
asp:DropDownList>
<asp:Label ID="Label1" runat="server" Text="">asp:Label>
JavaScript:
<script type="text/javascript">
function display(id) {
var ddl = document.getElementById(id);
var label = document.getElementById('Label1');
label.innerHTML = 'You have selected : ' + ddl.value;
}
script>
please mark it as accepted if it is helpful to you...
Munesh SharmaPosted Nov 7, 2014, 3:58 AM
Something like this (don't forget the script manager)
Joginder BangerPosted Nov 7, 2014, 3:45 AM