Hi @Harun Ergün,
You just need to add an initial "select" value to a DropDownList.
<asp:ListItem Text="---Select---" Value="0" />
<script src="Scripts/jquery-3.4.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#ikametSehir").change(function () {
val = $("#ikametSehir option:selected").text();
alert(val);
var states = document.getElementById('ikametIlce');
states.classList.remove("hidden");
});
});
</script>
<style>
#ikametIlce.hidden { display:none; }
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="ikametSehir" runat="server" Width="145px" ClientIDMode="Static">
<asp:ListItem Text="---Select---" Value="0" />
<asp:ListItem Value="AF">Afghanistan</asp:ListItem>
<asp:ListItem Value="AL">Albania</asp:ListItem>
<asp:ListItem Value="DZ">Algeria</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="ikametIlce" runat="server" Width="145px" class="hidden" >
<asp:ListItem Text="---Select---" Value="0" />
<asp:ListItem Value="AF">Afghanistan</asp:ListItem>
<asp:ListItem Value="AL">Albania</asp:ListItem>
<asp:ListItem Value="DZ">Algeria</asp:ListItem>
<asp:ListItem Value="AS">American Samoa</asp:ListItem>
</asp:DropDownList>
</div>
</form>
</body>
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.