last day (14 days later) » 

10:11 AM
0
A: Highlight tags which is not available into the list

Shaunak DUse beforeTagAdded event and compare the tags added to sampleTags, beforeTagAdded: function (event, ui) { if ($.inArray(ui.tagLabel,sampleTags) == -1) { $(ui.tag).css('background', 'red') //you can use `addClass()` here instead of .css() } ...

 
Thanks Its working fine but if the values of ` <input name="tags" id="mySingleFieldTags" value="sony,hp,Dell">` Already exist then its not working .. for that any solution ?
 
I didn't get you. The sony,hp,dell are not present in the sampleTags array. So they should be highlighted right? jsfiddle.net/uVxXg/7
 
I am using the same thing but its not working :( @Shaunak D
 
What does <%= this.SuggestionList %> return?
 
it's a List<string>
 
10:11 AM
I think the problem is in lin var sampleTags = [<%= this.SuggestionList %>];, that will not create javascript array. Can you do console.log(sampleTags) after this line tell what you see in console.
 
Sir when the input values are empty then its working fine... is any other way to achieve this ???
Sir where do I put the line console.log(sampleTags) ??
 
Can you show your HTML code?
View code
 
okay
 
Put console.log(sampleTags) below line var sampleTags = [<%= this.SuggestionList %>]; and check your browser console
 
<script>
$(function () {
$.ajax({
url: 'UpdateSingImgKwds.aspx/GetKeywords',
type: 'GET',
datatype: "json",
contentType: "application/json; charset=utf-8",
success: function (res) {
$('#singleFieldTags').tagit({
caseSensitive: false,
availableTags: res.d,
allowSpaces: true,
singleField: true,
singleFieldNode: $('#txtCompKwds'),
beforeTagAdded: function (event, ui) {
if ($.inArray(ui.tagLabel, res.d) == -1) {
$(ui.tag).css('background', 'yellow')
}
}

});

},
failure: function (err) {
alert(err);
okay sir let me try
 
10:14 AM
Dont call me Sir. I might be younger than you :P
 
hehehe Okay
:D
 
Btw, availableTags: res.d, this looks different code
 
See my code
 
What is res.d what does it contain?
List<string>?
 
and its a success response i get the code behind
i am using WebMethod to get the values from database
 
10:18 AM
Try this code
 
[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())
{
 
beforeTagAdded: function (event, ui) {
if ((res.d).indexOf(ui.tagLabel) == -1) {
$(ui.tag).css('background', 'red')
}
}
 
okay let me try
ya now its working
whats the problem actually ??
BTW thank you so much ^_^
 
The problem is toArray() in ASP webmethod return different array in Javascript
Glad to Help :)
Please accept the answer
 
Okay ya sure :)
 
10:23 AM
You are from India?
 
thanks once again ...actually its a imp task for me :)
 
MVC developer? or just ASP.net?
You are welcome.
 
ya i m from India WBU ?
 
Yes, Pune
 
Just ASP.net
 
10:24 AM
you? Your name?
 
Ohhh!! I am from delhi
my name is grima
grima rawat
:)
 
Good to know I helped an Indian :)
Goodluck with your important task
You work in a company?
 
hehehe same here :)
thank you so much
PetoIT
 
Or studying?
 
no no working of-course :)
 
10:26 AM
You are welcome. No need to say thankyou. even I learnt that arrays in ASP.NET dont match
hehe
 
Okay
PetroIT*
 
Okay good.
 
and your company ?
 
Cybage
 
great :)
 
10:27 AM
Please mark the answer as accepted before you leave. :)
 
working as ?
 
MVC lead
and also Angular JS and jQuery.
 
OMG .. Great ..
i have only one year experience :D
 
Since when are you working?
 
last may :D
 
10:30 AM
Okay good
 
Your good name ?
 
I have two year experience
Shaunak Deshpande
 
Okay nice to chat with you Shaunak Sir :P
 
Haha same here Grima Mam
 
Hope help me in future for further issues in Jquery :)
i only have little bit knowledge of jquery
 
10:43 AM
Yes sure
Its easy to learn too
 
Thank you so much
every experienced person say the same line :P
 
haha. No! actually it s been just 8-10 months I learnt jQuery.
It is definitely easier than .NET
:P
 
Ohh!! then I need to learn from you ;)
What's your fee n oll ?? :D
Need to go now.. nice to chat with you Shaunak :)
bye
 
11:26 AM
haha I teach for free.
 
 
1 hour later…
12:39 PM
Post your code here
 
okay
 
Only ajax code
 
[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public static string[] GetKeywords()
{
List<string> lst = new List<string>();
string queryString = "select LOWER(Keyword) from SIB_KWD_Library";
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())
LOWER(Keyword) is not working actually.
<script>
$(function () {
$.ajax({
url: 'UpdateSingImgKwds.aspx/GetKeywords',
type: 'GET',
datatype: "json",
contentType: "application/json; charset=utf-8",
success: function (res) {
$('#singleFieldTags').tagit({
caseSensitive: false,
availableTags: res.d,
allowSpaces: true,
singleField: true,
singleFieldNode: $('#txtCompKwds'),
beforeTagAdded: function (event, ui) {

if ((res.d).indexOf(ui.tagLabel.toLowerCase()) == -1) {
$(ui.tag).css('background', '#fff1b5')
}
}

});

},
failure: function (err) {
 
Do you know how to use .console.log()?
In your ajax success :

Write

success: function (res) {
console.log(res.d);
...
See browser console. Press f12 in google chrome
 
okay let me check\
Showing Array[5570]
something like [0 … 99]
0: "1995"
1: "16th Century"
2: "17th Century"
3: "18th Century"
4: "19th Century"
5: "19th Century Style"
6: "20th Century Style"
7: "24 Hrs"
8: "360-degree View"
9: "4x4"
10: "A Helping Hand"
11: "Abalone"
12: "Abandoned"
13: "Abdomen"
14: "Above"
 
12:56 PM
Btw, if you are using linq, try

lst = lst.ConvertAll(d => d.ToLower());
return lst.ToArray();
 
Okay let me try :)
thanks now working fine
you are genius (y)
 
success: function (res) {
var data= res.d;
$.each(data, function (index) {
data[index] = data[index].toLowerCase()
});
.....
Here is another runtime solution
Glad to help :)
 
hehehe to much solutions from your end ...great ^_^
 
Haha. Leaving office now. Bye
 
mee too bye
tc
 

last day (14 days later) »