Hi @Harun Ergün,
You can refer to the code below:
<script src="Scripts/jquery-3.4.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#ikametSehir").change(function () {
var val = $("#ikametSehir option:selected").text();
alert(val);
$("#ikametIlce").prop("disabled", false);
var val = $('#ikametIlce').val();
if (val == "0") {
alert("please select town");
}
});
$("#ikametIlce").change(function () {
var val = $('#ikametIlce').val();
if (val == "0") {
alert("error");
}
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="ikametSehir" runat="server" Width="145px">
<asp:ListItem Value="0">Afghanistan</asp:ListItem>
<asp:ListItem Value="1">Albania</asp:ListItem>
<asp:ListItem Value="2">Algeria</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="ikametIlce" runat="server" Width="145px" Enabled="false" >
<asp:ListItem Value="0">İlçe Seçiniz</asp:ListItem>
<asp:ListItem Value="1">Albania</asp:ListItem>
<asp:ListItem Value="2">Algeria</asp:ListItem>
<asp:ListItem Value="3">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.