Forms Data Controls :: How To Highlight Words In A Repeater When Match The Searched Words
Nov 17, 2010
I have a pretty basic search feature on a site that queries a sqldb with a sqldarasource, and then displays the results on a page, in a panel within a Repeater. I'd like to figure out if it's possible to somehow highlight the words the user searched on as they are displayed in the search results. The code below is my repeater. Do you know of any way to manipulate the Title or Description if the words in it's body match the words searched?
How to highlight searched words in gridview when serach performed on multiple column, i have 5 column in gridview and i perform search through text box and a button and bind gridview with searched record on all 5 column...
How to highlight searched keyword on all 5 column...
I have everything working as I wanted except that when I search for the keyword and if the keyword is in an URL, it messes up the link. For instance if I search for music, the keyword in the URL is replaced by
[Code]....
so in the end the URL is like this:
[Code]....
How do I avoid replacing the keyword if the keyword is an URL? Someone mentioned using IndexOf but I'm not sure.
I have a longer text and some keywords. I want to highlight these keywords in my text. That is no problem with this code:
private static string HighlightKeywords2(string keywords, string text) { // Swap out the ,<space> for pipes and add the braces Regex r = new Regex(@", ?"); keywords = "(" + r.Replace(keywords, @"|") + ")"; // Get ready to replace the keywords r = new Regex(keywords, RegexOptions.Singleline | RegexOptions.IgnoreCase); // Do the replace return r.Replace(text, new MatchEvaluator(MatchEval2)); } private static string MatchEval2(Match match) { if (match.Groups[1].Success) { return "<b>" + match.ToString() + "</b>"; } return ""; //no match }
But when the word"tournament" is in the text and the keyword "tour" it becomes <b>tour</b>nament. I want to it to highlight the complete word: <b>tournament</b>.
I have 1 Datalist and BTNsearch in my page below is SP
ALTER procedure [dbo].[AdminSearchP] AS BEGIN SELECT * FROM House_p WHERE ID IN( SELECT DISTINCT houseP.ID FROM House_p houseP,SearchTerm WHERE [Description] LIKE '%' + SearchTerm.Name + '%') END
this SP show in dataList data that contain some words that I define in SerachTerm table
Now I want when I click on button and it show data in datalist it highlight the words in datalist that I define in SearchTerm Table i.e in serchTerm table i define below words
Paris-India-Itally-Germany
when I click on button it search in House_p table in Description Column and if in this column be above words show it in datalist
Like below
Name Description Sara She is from India
Now I want when show data in datalist it bold or Highlight the words that I define in SearchTerm table Like below
Name Description Sara She is from India How I can do it?
I am having some text boxes in my webform. I need to set numbers of words for each textbox. if i put more than defined no of words it should show msgs or popup msgs whatever it may be.
I have been stuck on an issue that is driving me mad and I bet its simple. I have a Textbox with a gridview and a LINQ statement in code behind that populates the data source of the gridview at page load.
The Textbox is used as a filter for the where clause in the Linq statement. All works as expected however I want to be able to use more than one word as a filter. This is the problem. I take the textbox string and convert to an array
Dim aryTextFile() As String = SearchString.Split(",")
But I need to figure how to pass the values of the array as parameters for the Linq Statement. I need to return all rows that have either a match for LocationName AND/OR Address AND/OR City. I thought of something like this but it fails.
Dim db As New DCLocationsDataContext Dim q = From t In db.Locations _ Where t.City AndAlso t.LocationName AndAlso t.Address Like aryTextFile _ Select t GridView1.DataSource = q GridView1.DataBind()
I like to use GridView because it is easy and flexible to work with. However, I found it quite frustration when it comes to display a column with a large chuck of words into the value of that particular column. Is there anyway to restrict how many words should only be display in a particular column rather than let it expands to cope up to display all the word. For example, I'm trying to display 20w and normally it would display
wwwwwwwwwwwwwwwwwww
but I would like to limit to 5 words in a line so it's going to be
I'd like to make some words of a cell in gridview Bold. For example - "MRN No.: SI0021848 Name: Cherry" like my attachment. I could query this field value from database but don't know how to make some words Bold. How to do it?
I have a textbox and a gridview which is bound to a table what I want to achieve is a solution where lets say there are two records - e.g. "1. Book and 2. Red", i want a user to type in those words and the gridview shows the results as followed;
1. Book 2. Red
I have set up the sql data source and everything and my like operator is this.
I found this usefull code in this website but i was wondering a way to select a multiple names in textbox inside GridView. I have seen one exampe on this website but the example is not in GridView. Here is my code that works fine now but it does not let me select multiple names:
I need to implement a stored procedure for search with 1 fileldkeywords(jobtitle,skills,company name....etc) everything is in different tables?how i will query this?any samples using dynamic query or temporary tables
I am probably doing this wrong but I want to take all words entered in to a text box and return all records that contain any or all of the words. Can any one point me in the right direction?
protected void ldsGvFaqs_Selecting(object sender, LinqDataSourceSelectEventArgs e) { if (txbSearch.Text.Length > 0) { string temp = string.Empty; string[] words = txbSearch.Text.Split(' '); int counter = words.Length; foreach (var word in words) { temp += "Tags.Contains('" + word + "')"; counter -= 1; if (counter > 0) { temp += " || "; } } ldsGvFaqs.Where = temp; } }
But I get the following error, Character literal must contain exactly one character.
i want to search the words and nearby words from the xml file.I dont know how to start this with asp.net. I have a xml file i want to serialize it using xmlelement and xmlatrribute.but i don't know how to define it. and use it. I also want to use hash table that contain this xml file but how do i define keys and values with the xmlelement and attribute. I am new to this.
i am having a webpage,in that webpage the total salary is 19563,but in words it shows "Twenty Thousands Six Hundreds Sixty Three",i dont no how to do this..what changes i want to do.this is my code
Dim num As Integer num = lblnetsal.Text Label2.Text = NumberToWords(num) End Sub
How i can count year from birthday people in mssql server? example: if day equal 11 month 29 day then less 1 year; if day equal 1 year 11 month 29 day then less 2 year.
I want to convert amount in words (Indian currency only) using javascript/jquery.e.g. 765828.45 = Seven lakh sixty five thousand eight hundred twenty eight and fourty five paise only