2013-04-25 17 views
0

我可以使用javascript/jquery綁定asp.net dropdownlist嗎?我從web方法中獲取來自jquery ajax的數據,所以我想在這一點上避免回發。但我仍然想使用客戶端腳本綁定後使用服務器端代碼進行回發並保存所有數據(即,我仍然可以執行此操作)。我可以使用javascript/jquery綁定asp.net dropdownlist嗎?

是否有可能,有人可以解釋我是如何做到的?

感謝,

回答

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); 
        } 
       }); 
      }); 
     }); 
+0

我已經嘗試了很多東西,最終還是放棄了這個念頭到做這個。問題是,一旦asp.net控件被更改,事件驗證失敗。即我永遠無法一起使用2種技術。我不能重寫所有的服務器代碼,所以我放棄了做部分ajax的想法。謝謝。 – lawphotog 2013-05-31 12:58:44

相關問題