jQuery UI Ajax Autocomplete case sensitive ASP.net MVC
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
here I m using Jquery-ui AutoComplete function for my search box but if I search lowercase Letter Uppercase Didn't come to the suggestion List How to Add Uppercase & Lowercase case sensitive Search For this Autocomplete Ajax ASP.net MVC
And if Possible to add matching text bold search suggestion List?
View Page
<input id="app-search">
<script src="https://code.jquery.com/jquery-2.1.1.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.css" rel="stylesheet" />
<script>
(function() {
$("#app-search").autocomplete({
minLength: 1, //start letter search
selectFirst: true,
autoFocus: true,
source: function(request, response) {
$.ajax({
url: '@Url.Action("GetSearchType")',
type: "POST",
dataType: "json",
data: {
SearchType: @Model.SearchType,
Prefix: request.term
},
success: function(data) {
if (!data.length) {
var result = [{
label: 'No record(s) found',
value: response.term
}];
response(result);
} else {
response($.map(data.slice(0, 10), function(item) {
return {
label: item.OrganizationName,
value: item.OrganizationName
};
}))
}
}
})
},
});
});
</script>
This Controller In MVC Asp.net
[HttpPost]
public JsonResult GetSearchType(string Prefix)
{
List<OrganizationModel> OrganizationList = new List<OrganizationModel>()
{
new OrganizationModel {OrganizationName = "Apple" },
new OrganizationModel { OrganizationName = "name" },
new OrganizationModel { OrganizationName = "New" },
};
var CourseList = (from C in OrganizationList
where C.OrganizationName.StartsWith(Prefix)
select new { C.OrganizationName });
return Json(CourseList, JsonRequestBehavior.AllowGet);
}
c# jquery linq jquery-ui asp.net-ajax
add a comment |
here I m using Jquery-ui AutoComplete function for my search box but if I search lowercase Letter Uppercase Didn't come to the suggestion List How to Add Uppercase & Lowercase case sensitive Search For this Autocomplete Ajax ASP.net MVC
And if Possible to add matching text bold search suggestion List?
View Page
<input id="app-search">
<script src="https://code.jquery.com/jquery-2.1.1.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.css" rel="stylesheet" />
<script>
(function() {
$("#app-search").autocomplete({
minLength: 1, //start letter search
selectFirst: true,
autoFocus: true,
source: function(request, response) {
$.ajax({
url: '@Url.Action("GetSearchType")',
type: "POST",
dataType: "json",
data: {
SearchType: @Model.SearchType,
Prefix: request.term
},
success: function(data) {
if (!data.length) {
var result = [{
label: 'No record(s) found',
value: response.term
}];
response(result);
} else {
response($.map(data.slice(0, 10), function(item) {
return {
label: item.OrganizationName,
value: item.OrganizationName
};
}))
}
}
})
},
});
});
</script>
This Controller In MVC Asp.net
[HttpPost]
public JsonResult GetSearchType(string Prefix)
{
List<OrganizationModel> OrganizationList = new List<OrganizationModel>()
{
new OrganizationModel {OrganizationName = "Apple" },
new OrganizationModel { OrganizationName = "name" },
new OrganizationModel { OrganizationName = "New" },
};
var CourseList = (from C in OrganizationList
where C.OrganizationName.StartsWith(Prefix)
select new { C.OrganizationName });
return Json(CourseList, JsonRequestBehavior.AllowGet);
}
c# jquery linq jquery-ui asp.net-ajax
add a comment |
here I m using Jquery-ui AutoComplete function for my search box but if I search lowercase Letter Uppercase Didn't come to the suggestion List How to Add Uppercase & Lowercase case sensitive Search For this Autocomplete Ajax ASP.net MVC
And if Possible to add matching text bold search suggestion List?
View Page
<input id="app-search">
<script src="https://code.jquery.com/jquery-2.1.1.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.css" rel="stylesheet" />
<script>
(function() {
$("#app-search").autocomplete({
minLength: 1, //start letter search
selectFirst: true,
autoFocus: true,
source: function(request, response) {
$.ajax({
url: '@Url.Action("GetSearchType")',
type: "POST",
dataType: "json",
data: {
SearchType: @Model.SearchType,
Prefix: request.term
},
success: function(data) {
if (!data.length) {
var result = [{
label: 'No record(s) found',
value: response.term
}];
response(result);
} else {
response($.map(data.slice(0, 10), function(item) {
return {
label: item.OrganizationName,
value: item.OrganizationName
};
}))
}
}
})
},
});
});
</script>
This Controller In MVC Asp.net
[HttpPost]
public JsonResult GetSearchType(string Prefix)
{
List<OrganizationModel> OrganizationList = new List<OrganizationModel>()
{
new OrganizationModel {OrganizationName = "Apple" },
new OrganizationModel { OrganizationName = "name" },
new OrganizationModel { OrganizationName = "New" },
};
var CourseList = (from C in OrganizationList
where C.OrganizationName.StartsWith(Prefix)
select new { C.OrganizationName });
return Json(CourseList, JsonRequestBehavior.AllowGet);
}
c# jquery linq jquery-ui asp.net-ajax
here I m using Jquery-ui AutoComplete function for my search box but if I search lowercase Letter Uppercase Didn't come to the suggestion List How to Add Uppercase & Lowercase case sensitive Search For this Autocomplete Ajax ASP.net MVC
And if Possible to add matching text bold search suggestion List?
View Page
<input id="app-search">
<script src="https://code.jquery.com/jquery-2.1.1.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.css" rel="stylesheet" />
<script>
(function() {
$("#app-search").autocomplete({
minLength: 1, //start letter search
selectFirst: true,
autoFocus: true,
source: function(request, response) {
$.ajax({
url: '@Url.Action("GetSearchType")',
type: "POST",
dataType: "json",
data: {
SearchType: @Model.SearchType,
Prefix: request.term
},
success: function(data) {
if (!data.length) {
var result = [{
label: 'No record(s) found',
value: response.term
}];
response(result);
} else {
response($.map(data.slice(0, 10), function(item) {
return {
label: item.OrganizationName,
value: item.OrganizationName
};
}))
}
}
})
},
});
});
</script>
This Controller In MVC Asp.net
[HttpPost]
public JsonResult GetSearchType(string Prefix)
{
List<OrganizationModel> OrganizationList = new List<OrganizationModel>()
{
new OrganizationModel {OrganizationName = "Apple" },
new OrganizationModel { OrganizationName = "name" },
new OrganizationModel { OrganizationName = "New" },
};
var CourseList = (from C in OrganizationList
where C.OrganizationName.StartsWith(Prefix)
select new { C.OrganizationName });
return Json(CourseList, JsonRequestBehavior.AllowGet);
}
c# jquery linq jquery-ui asp.net-ajax
c# jquery linq jquery-ui asp.net-ajax
edited Jan 4 at 8:11
Robin Hood
asked Jan 3 at 7:10
Robin HoodRobin Hood
219
219
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You need to use this overload of StartsWith
and specify by using StringComparison type so that it should be case insensitive comparison:
C.OrganizationName.StartsWith(Prefix, StringComparison.InvariantCultureIgnoreCase)
Thanks @Ehsan Sajjad It's working <3
– Robin Hood
Jan 3 at 7:22
if Possible to add matching text bold for search suggestion List?
– Robin Hood
Jan 3 at 8:18
not sure but it would be done on the client side in javascript
– Ehsan Sajjad
Jan 3 at 8:24
check this: stackoverflow.com/q/3344804/1875256
– Ehsan Sajjad
Jan 3 at 8:25
yes is Possible I add the answer here anyway thanks
– Robin Hood
Jan 3 at 8:27
add a comment |
Add matching text bold Autocomplete suggestion List is Possible
Inside of function add this code
$.ui.autocomplete.prototype._renderItem = function (ul, item) {
item.label = item.label.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + $.ui.autocomplete.escapeRegex(this.term) + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>");
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a>" + item.label + "</a>")
.appendTo(ul);
};
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54017810%2fjquery-ui-ajax-autocomplete-case-sensitive-asp-net-mvc%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to use this overload of StartsWith
and specify by using StringComparison type so that it should be case insensitive comparison:
C.OrganizationName.StartsWith(Prefix, StringComparison.InvariantCultureIgnoreCase)
Thanks @Ehsan Sajjad It's working <3
– Robin Hood
Jan 3 at 7:22
if Possible to add matching text bold for search suggestion List?
– Robin Hood
Jan 3 at 8:18
not sure but it would be done on the client side in javascript
– Ehsan Sajjad
Jan 3 at 8:24
check this: stackoverflow.com/q/3344804/1875256
– Ehsan Sajjad
Jan 3 at 8:25
yes is Possible I add the answer here anyway thanks
– Robin Hood
Jan 3 at 8:27
add a comment |
You need to use this overload of StartsWith
and specify by using StringComparison type so that it should be case insensitive comparison:
C.OrganizationName.StartsWith(Prefix, StringComparison.InvariantCultureIgnoreCase)
Thanks @Ehsan Sajjad It's working <3
– Robin Hood
Jan 3 at 7:22
if Possible to add matching text bold for search suggestion List?
– Robin Hood
Jan 3 at 8:18
not sure but it would be done on the client side in javascript
– Ehsan Sajjad
Jan 3 at 8:24
check this: stackoverflow.com/q/3344804/1875256
– Ehsan Sajjad
Jan 3 at 8:25
yes is Possible I add the answer here anyway thanks
– Robin Hood
Jan 3 at 8:27
add a comment |
You need to use this overload of StartsWith
and specify by using StringComparison type so that it should be case insensitive comparison:
C.OrganizationName.StartsWith(Prefix, StringComparison.InvariantCultureIgnoreCase)
You need to use this overload of StartsWith
and specify by using StringComparison type so that it should be case insensitive comparison:
C.OrganizationName.StartsWith(Prefix, StringComparison.InvariantCultureIgnoreCase)
answered Jan 3 at 7:16
Ehsan SajjadEhsan Sajjad
51.3k1168126
51.3k1168126
Thanks @Ehsan Sajjad It's working <3
– Robin Hood
Jan 3 at 7:22
if Possible to add matching text bold for search suggestion List?
– Robin Hood
Jan 3 at 8:18
not sure but it would be done on the client side in javascript
– Ehsan Sajjad
Jan 3 at 8:24
check this: stackoverflow.com/q/3344804/1875256
– Ehsan Sajjad
Jan 3 at 8:25
yes is Possible I add the answer here anyway thanks
– Robin Hood
Jan 3 at 8:27
add a comment |
Thanks @Ehsan Sajjad It's working <3
– Robin Hood
Jan 3 at 7:22
if Possible to add matching text bold for search suggestion List?
– Robin Hood
Jan 3 at 8:18
not sure but it would be done on the client side in javascript
– Ehsan Sajjad
Jan 3 at 8:24
check this: stackoverflow.com/q/3344804/1875256
– Ehsan Sajjad
Jan 3 at 8:25
yes is Possible I add the answer here anyway thanks
– Robin Hood
Jan 3 at 8:27
Thanks @Ehsan Sajjad It's working <3
– Robin Hood
Jan 3 at 7:22
Thanks @Ehsan Sajjad It's working <3
– Robin Hood
Jan 3 at 7:22
if Possible to add matching text bold for search suggestion List?
– Robin Hood
Jan 3 at 8:18
if Possible to add matching text bold for search suggestion List?
– Robin Hood
Jan 3 at 8:18
not sure but it would be done on the client side in javascript
– Ehsan Sajjad
Jan 3 at 8:24
not sure but it would be done on the client side in javascript
– Ehsan Sajjad
Jan 3 at 8:24
check this: stackoverflow.com/q/3344804/1875256
– Ehsan Sajjad
Jan 3 at 8:25
check this: stackoverflow.com/q/3344804/1875256
– Ehsan Sajjad
Jan 3 at 8:25
yes is Possible I add the answer here anyway thanks
– Robin Hood
Jan 3 at 8:27
yes is Possible I add the answer here anyway thanks
– Robin Hood
Jan 3 at 8:27
add a comment |
Add matching text bold Autocomplete suggestion List is Possible
Inside of function add this code
$.ui.autocomplete.prototype._renderItem = function (ul, item) {
item.label = item.label.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + $.ui.autocomplete.escapeRegex(this.term) + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>");
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a>" + item.label + "</a>")
.appendTo(ul);
};
add a comment |
Add matching text bold Autocomplete suggestion List is Possible
Inside of function add this code
$.ui.autocomplete.prototype._renderItem = function (ul, item) {
item.label = item.label.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + $.ui.autocomplete.escapeRegex(this.term) + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>");
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a>" + item.label + "</a>")
.appendTo(ul);
};
add a comment |
Add matching text bold Autocomplete suggestion List is Possible
Inside of function add this code
$.ui.autocomplete.prototype._renderItem = function (ul, item) {
item.label = item.label.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + $.ui.autocomplete.escapeRegex(this.term) + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>");
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a>" + item.label + "</a>")
.appendTo(ul);
};
Add matching text bold Autocomplete suggestion List is Possible
Inside of function add this code
$.ui.autocomplete.prototype._renderItem = function (ul, item) {
item.label = item.label.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + $.ui.autocomplete.escapeRegex(this.term) + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>");
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a>" + item.label + "</a>")
.appendTo(ul);
};
answered Jan 3 at 8:25
Robin HoodRobin Hood
219
219
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54017810%2fjquery-ui-ajax-autocomplete-case-sensitive-asp-net-mvc%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown