2011-11-16 46 views
1

請幫我我在這裏呆了很長時間沒有解決方案,我試圖使用jQuery令牌輸入顯示來自asp.net頁面的選擇結果,頁面調用正確,並生成正確的JSON格式,但結果未顯示在下拉列表中,這裏是HTML中輸入字段的代碼,不能從asp.net頁面獲得結果用於jQuery令牌輸入下拉

<div> 
     <input type="text" id="textBox2" name="blah2" runat="server"/> 
     <input type="button" value="Submit" /> 
     <script type="text/javascript"> 
      $(document).ready(function() { 
       $("#textBox2").tokenInput("Default.aspx", { 
        theme: "facebook" 
       }); 
      }); 
     </script> 
    </div> 

和aspx頁面的代碼是這樣的:

protected void Page_Load(object sender, EventArgs e) 
    { 
     Response.ContentType = "application/json"; 
     string searchParam = Request.QueryString["q"]; 
     Country country = new Country(); 
     country.name = searchParam; 
     country.id = searchParam; 
     List<Country> countryList = new List<Country>(); 
     countryList.Add(country); 
     JavaScriptSerializer serializer = new JavaScriptSerializer(); 
     string serialized = serializer.Serialize(countryList); 
     Response.Write(serialized); 
    } 

沒有任何東西id的更多我應該做的, 請大家幫忙, 在此先感謝,

回答

0

我用令牌輸入來調用一個web服務,而不是一個aspx頁面,它對我很好。

0

在的Page_Load

順便說一句末尾添加Response.End()方法調用,服務器控件使用以下選擇:$("#<%= textBox2.ClientID %>")

+0

我試過你的解決方案,但也沒有任何反應,其實我用另一種方法解決了這個問題,我已經使用令牌輸入來調用Web服務而不是aspx頁面,它爲我工作得很好... –