簡體   English   中英

我可以使用javascript / jquery綁定asp.net下拉列表嗎?

[英]Can I bind asp.net dropdownlist using javascript/jquery?

我可以使用javascript / jquery綁定asp.net下拉列表嗎? 我從Web方法的jquery ajax獲取數據,因此我想避免此時的回發。 但是我仍然想做回發,並在使用客戶端腳本綁定之后使用服務器端代碼保存所有數據(即,我仍然能夠執行此dropdownlist1.selecteditem.text )。

是否可以,有人可以向我解釋如何完成?

謝謝,

使用Json Ajax

句法:

$.ajax({
dataType: "json",
url: url,
data: data,
success: success
});

查看json的簡單示例:

<script type="text/javascript">
        $(document).ready(function () {
            var msgbox = $("#status");
            $("#Button1").click(function () {
                $.ajax({
                    type: "POST",

                    //Page Name (in which the method should be called) and method name
                    url: "BeginJson.aspx/CheckDateTime",
                    // If you want to pass parameter or data to server side function you can try line
                   // data: "{}",
                    //else If you don't want to pass any value to server side function leave the data to blank line below
                    data: "{'args':'Somnath'}",


                    contentType: "application/json; charset=utf-8",

                    dataType: "json",

                    success: function (msg) {
                        //Got the response from server and render to the client
                        msgbox.html(msg.d);
                    }
                });
            });
        });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM