Monday, 15 March 2010

c# - How to display certain selected words bolder in asp:hyperlink text -



c# - How to display certain selected words bolder in asp:hyperlink text -

i have asp:repeater command on .aspx , in code behind binding datasource collection of type keyvaluepair[]<literal,string>. choosing literal surround selected words in literal text <strong> or <b> html tag. succeeded in doing not finding way display literal text in asp:hyperlink's text part of asp:repeater

my .aspx code follow:

<asp:repeater id="replinks" runat="server"> <itemtemplate> <div onclick="window.open('<%# ((keyvaluepair<literal,string>)container.dataitem).value %>','_blank');"> <div> <asp:hyperlink id="hyperlink1" runat="server" navigateurl="<%# ((keyvaluepair<literal,string>)container.dataitem).value %>" text="<%#((keyvaluepair<literal,string>)container.dataitem).key.text %>" font-size='large' forecolor='blue' font-names="open sans" cssclass="linkstyle" /> <br /> </div> </div> </itemtemplate> </asp:repeater>

i need help on how display .key.text part in asp:hyperlink.

i added keyvaluepair follow:

char[] seperator = { ' ' }; string[] explodedstring = results1[index].key.split(seperator); list<string> query= new list<string>(textbox1.text.trim().tolowerinvariant().split(seperator,stringsplitoptions.removeemptyentries)); (int = 0; < explodedstring.length; i++) { if (query.contains(explodedstring[i].tolowerinvariant()) == true) { explodedstring[i] = "<strong>" + explodedstring[i] + "<strong>"; } } literal temp = new literal(); temp.text = explodedstring.tostring(); trycurrentwindow[index] = new keyvaluepair<literal, string>(temp, results1[index].value);

here trycurrentwindow keyvaluepair[] , explodedstring[] text string splitted '' char want modify , query[] list of keywords

problem:

you not closing <strong> tag </strong>.

you doing tostring() string[] array.

updated line:

explodedstring[i] = "<strong>" + explodedstring[i] + "</strong>";

also alter below code:

literal temp = new literal(); temp.text = explodedstring.tostring();

with this:

literal temp = new literal(); temp.text = string.join(" ", explodedstring);

as indexes modified in string[] array. required bring together array modified string[] array.

updated code snippet:

char[] seperator = { ' ' }; string[] explodedstring = results1[index].key.split(seperator); list<string> query= new list<string>(textbox1.text.trim().tolowerinvariant().split(seperator,stringsplitoptions.removeemptyentries)); (int = 0; < explodedstring.length; i++) { if (query.contains(explodedstring[i].tolowerinvariant()) == true) { explodedstring[i] = "<strong>" + explodedstring[i] + "</strong>"; //changed } } literal temp = new literal(); temp.text = string.join(" ", explodedstring); //changed trycurrentwindow[index] = new keyvaluepair<literal, string>(temp, results1[index].value);

c# asp.net hyperlink

No comments:

Post a Comment