このフォーラムにはjqueryオートコンプリートコードがたくさんありますが、しかし、私はSharePoint/ASP.NET Webページのケースに合ったものは見つかりませんでした。私はjquery autocomplete linkに従った。それは役に立ちます。しかしasp.netのオートコンプリートjquery、ソースコードの後ろ
私のコードを見てください。
string[] source = new string[5];
source[0] = "c++";
source[1] = "java";
source[2] = "php";
source[3] = "coldfusion";
source[4] = "javascript";
を次にjqueryのコードに配列を渡す方法:
<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("asp:TextBox#TextBox3").autocomplete({
source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"]
});
});
</script>
</asp:Content>
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<table>
<tr><td>
<asp:Label ID="Label4" runat="server" Text="Qode"></asp:Label></td><td>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</td></tr>
</table>
質問
1. Can I use the code ` $("asp:TextBox#TextBox3")?`
2. If the source comes from code behind instead of hard copy strings, how to do it?
はのは、背後にあるコードにしましょうか? 多くのありがとうございます。
私は$(document).ready(function(){$( ""))オートコンプリートを使用していますが、機能しません。 –
私のコードをもう一度チェックしてください。セレクタ。<%=の前に#がなければjQueryセレクタが正しく動作しません。 –
jason.netなどのサードパーティのコンポーネントを利用できない場合は、[JavaScriptSerializer](http://msdn.microsoftあなたの文字列が動的な場合は、薄いページメソッドをホストすることができます。これを使用すると、ajaxを使用して取得することができます。また、取得することもできます(例:.com/en-us/library/system.web.script.serialization.javascriptserializer(VS.90).aspx)結果は動的になります – Roman