0

我可以使用 javascript/jquery 绑定 asp.net 下拉列表吗?我从 web 方法从 jquery ajax 获取数据,所以我想在这一点上避免回发。dropdownlist1.selecteditem.text但是我仍然想在使用客户端脚本绑定它之后使用服务器端代码进行回发并保存所有数据(即我仍然可以这样做)。

有可能吗,有人可以解释一下如何做到吗?

谢谢,

4

1 回答 1

0

使用 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);
                    }
                });
            });
        });
于 2013-05-31T07:28:37.840 回答