Hi, i need a function in csharp which will check in a for a string in a text.(May be ASp.NEt label/textbox text). the function should check if a particular text exist in it. It should make it the text bold.
How this should be done? Regards
protected void Button1_Click(object sender, EventArgs e)
{
string str="gsdahfgsdaj";
if(str.Contains("yourvalue"))
Label1.Font.Bold =
true ;
}
<b>
</b>
<asp:Label ID="Label1" runat="server" Text="Hello World! How are you all"></asp:Label> using System.Text;
using System.Text;
protected void Button1_Click(object sender, EventArgs e) { StringBuilder str = new StringBuilder(); string[] data = Label1.Text.Split(' '); foreach (string s in data) { if (s.Contains("World")) { str.Append("<b><font color='green'>"); str.Append(s); str.Append("</b></font>"); } else { str.Append(" " + s); } } Response.Write(str.ToString()); }