highlight search phrase in dreamwaever mx 2004
Code
Hi
Can anyone help solve this problem,
When I enter the variable into the datagrid,
all the <%=HighlightWord%> are the same even through the rest of the
results change correctly. i.e title and pageurl change for each record,
but the "><%=HighlightWord%> is the same for each.
Can anyone help solve this problem.
Below is the code:
********* dataset Code****************
<MM:DataSet
runat="Server"
id="spQueryResults"
IsStoredProcedure="true"
CreateDataSet="true"
ConnectionString='<%#
System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_STRING_*********"]
%>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_DATABASETYPE_*********"]
%>'
CommandText="dbo.sp_TDQueryResults"
FailureURL='<%# "../error.htm" %>' PageSize="10"
>
<Parameters>
<Parameter Name="@RETURN_VALUE" Type="Int" Direction="ReturnValue" />
<Parameter Name="@SearchPhrase" Value='<%#
((Request.QueryString["TxtQuery"] != null) &&
(Request.QueryString["TxtQuery"].Length > 0)) ?
Request.QueryString["TxtQuery"] : "" %>' Type="VarChar" Size="100"
Direction="Input" />
</Parameters>
</MM:DataSet>
*****************Body Code*****************
void Page_Load(Object Src, EventArgs E)
{ inputString = Request.QueryString["TxtQuery"];
string[] words = GetQueryStringToArray(Request.QueryString["TxtQuery"].ToString())
;
Word1 = words[0];
Word2 = words[1];
Word3 = words[2];
Word4 = words[3];
Word5 = words[4];
Word6 = words[5];
HighlightWord = spQueryResults.FieldValue("PageDescription", null);
HighlightWord = Regex.Replace(HighlightWord, Word1, ""+Word1+"",
RegexOptions.IgnoreCase);
HighlightWord = Regex.Replace(HighlightWord, Word2, ""+Word2+"",
RegexOptions.IgnoreCase);
} public string[] GetQueryStringToArray(string inputString)
{
string[] finalSetOfWords = new string[6]; char[] separators = {' '};
string[] words = inputString.Split(separators);
for ( int i=0; i < 6; i++) { if(words.Length > i && inputString.Trim().Length > 0)
{
finalSetOfWords = words;
}
else
{ finalSetOfWords = "NNN";
}
} return finalSetOfWords; }
Datadrid details
<Columns> <asp:TemplateColumn runat="server">
<itemtemplate>
<span class="QuCssResultsTitle"><%#
spQueryResults.FieldValue("PageTitle", Container) %></span>
<span class="QuCssResultsBody"><%=HighlightWord%></span>
<span class="QuCssResultsURL"><%# spQueryResults.FieldValue("PageURL",
Container) %></span>
</itemtemplate></asp:TemplateColumn> </columns>
George |