<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>




<asp:DropDownList ID="ddlSample" runat="server" AutoPostBack="false">
    <asp:ListItem Text="Seçenek 1" Value="1"></asp:ListItem>
    <asp:ListItem Text="Seçenek 2" Value="2"></asp:ListItem>
</asp:DropDownList>

<div id="result"></div>

<script>
    $(document).ready(function () {
        $("#<%= ddlSample.ClientID %>").change(function () {
            var selectedValue = $(this).val();

            // Seçilen değeri bir AJAX isteği ile sunucuya gönderin
            $.ajax({
                type: "POST",
                url: "YourPage.aspx/HandleSelection", // Sunucu tarafındaki işleme gönderilecek URL
                data: JSON.stringify({ selectedValue: selectedValue }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (response) {
                    // Sunucu tarafından dönen sonucu işleyin
                    $("#result").html(response.d);
                },
                error: function (error) {
                    console.log(error);
                }
            });
        });
    });
</script>



<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:DropDownList ID="ddlSample" runat="server" AutoPostBack="false">
    <asp:ListItem Text="Seçenek 1" Value="1"></asp:ListItem>
    <asp:ListItem Text="Seçenek 2" Value="2"></asp:ListItem>
</asp:DropDownList>

<ajaxToolkit:UpdatePanel runat="server">
    <ContentTemplate>
        <asp:Label ID="lblResult" runat="server"></asp:Label>
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="ddlSample" EventName="SelectedIndexChanged" />
    </Triggers>
</ajaxToolkit:UpdatePanel>



protected void ddlSample_SelectedIndexChanged(object sender, EventArgs e)
{
    string selectedValue = ddlSample.SelectedValue;

    // Seçilen değeri kullanarak işlem yapın
    // Örnek olarak bir Label kontrolüne yazdırabiliriz:
    lblResult.Text = "Seçilen değer: " + selectedValue;
}

Yorumlar

Bu blogdaki popüler yayınlar

Dropdownlist

VMWare installation solution