C# 但是所有的关键字在浏览器源代码中都是可见的。我想直接从sql绑定它sever@Gitz请看我答案中的编辑。好的!!我正在尝试:)我会让你知道这没关系,但我的问题不像你回答的那样:(@Gitz编写一个ajax方法,使用WebMethod从服务器获取列表,并在
C# 但是所有的关键字在浏览器源代码中都是可见的。我想直接从sql绑定它sever@Gitz请看我答案中的编辑。好的!!我正在尝试:)我会让你知道这没关系,但我的问题不像你回答的那样:(@Gitz编写一个ajax方法,使用WebMethod从服务器获取列表,并在,c#,jquery,asp.net,jquery-ui,tag-it,C#,Jquery,Asp.net,Jquery Ui,Tag It,但是所有的关键字在浏览器源代码中都是可见的。我想直接从sql绑定它sever@Gitz请看我答案中的编辑。好的!!我正在尝试:)我会让你知道这没关系,但我的问题不像你回答的那样:(@Gitz编写一个ajax方法,使用WebMethod从服务器获取列表,并在内部成功使用您的tagit代码。@wix kid这就是我要寻找的。实际上,从代码隐藏直接调用很容易,但所有关键字都可以在浏览器源代码中看到。我想直接从sql绑定它sever@Gitz请看我答案中的编辑。好的!!我正在尝试:)我会让你知道这没关系
但是所有的关键字在浏览器源代码中都是可见的。我想直接从sql绑定它sever@Gitz请看我答案中的编辑。好的!!我正在尝试:)我会让你知道这没关系,但我的问题不像你回答的那样:(@Gitz编写一个ajax方法,使用WebMethod从服务器获取列表,并在内部成功使用您的tagit代码。@wix kid这就是我要寻找的。实际上,从代码隐藏直接调用很容易,但所有关键字都可以在浏览器源代码中看到。我想直接从sql绑定它sever@Gitz请看我答案中的编辑。好的!!我正在尝试:)我会让你知道这没关系,但我的问题不像你回答的那样:(@Gitz编写一个ajax方法,使用WebMethod从服务器获取列表,并在内部成功使用您的tagit代码。@wix kid这就是我要寻找的。实际上,从代码隐藏直接调用很容易,但所有关键字都可以在浏览器源代码中看到。我想直接从sql绑定它sever@Gitz请看我答案中的编辑。好的!!我正在努力:)我会让你知道的
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../JavaScript/tag-it.js"></script>
<link href="../CSS/tagit.ui-zendesk.css" rel="stylesheet" />
<link href="../CSS/jquery.tagit.css" rel="stylesheet" />
<script>
$(function(){
var sampleTags = [<%# this.SuggestionList %>];
//var sampleTags = ['c++', 'java', 'php', 'coldfusion', 'javascript', 'asp', 'ruby', 'python', 'c', 'scala', 'groovy', 'haskell', 'perl', 'erlang', 'apl', 'cobol', 'go', 'lua'];
$('#myTags').tagit();
$('#singleFieldTags').tagit({
availableTags: sampleTags,
allowSpaces: true,
singleFieldNode: $('#mySingleField')
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="content">
<p>
<input name="tags" id="mySingleField" value="Apple, Orange" disabled="true">
</p>
<ul id="singleFieldTags"></ul>
</div>
</form>
</body>
string queryString = "select * from SIB_KWD_Library ORDER BY Keyword asc";
using (SqlConnection connection = new SqlConnection(ConfigurationManager.AppSettings["vConnString"].ToString()))
{
using (SqlCommand command = new SqlCommand(queryString, connection))
{
connection.Open();
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
if (string.IsNullOrEmpty(SuggestionList))
{
SuggestionList += "\'" + reader["Keyword"].ToString() + "\'";
}
else
{
SuggestionList += ", \'" + reader["Keyword"].ToString() + "\'";
}
}
}
}
}
<script>
$(function(){
var sampleTags = [<%= this.SuggestionList %>];
//var sampleTags = ['c++', 'java', 'php', 'coldfusion', 'javascript', 'asp', 'ruby', 'python', 'c', 'scala', 'groovy', 'haskell', 'perl', 'erlang', 'apl', 'cobol', 'go', 'lua'];
$('#myTags').tagit();
$('#singleFieldTags').tagit({
availableTags: sampleTags,
allowSpaces: true,
singleFieldNode: $('#mySingleField')
});
});
</script>
<script>
$(function () {
$.ajax({
url: "http://"+location.host + '/Default.aspx/GetKeywords',
type: 'GET',
datatype: "json",
contentType: "application/json; charset=utf-8",
success: function(res) {
$('#singleFieldTags').tagit({
availableTags: res.d,
allowSpaces: true,
singleFieldNode: $('#mySingleField')
});
},
failure: function(err) {
alert(err);
}
});
});
</script>
[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public static string[] GetKeywords()
{
List<string> lst = new List<string>();
string queryString = "select * from SIB_KWD_Library ORDER BY Keyword asc";
using (SqlConnection connection = new SqlConnection(ConfigurationManager.AppSettings["vConnString"].ToString()))
{
using (SqlCommand command = new SqlCommand(queryString, connection))
{
connection.Open();
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
lst.Add(reader["Keyword"].ToString());
}
}
}
}
return lst.ToArray();
}