WB tips keywords Fuzzy query keyword color change

Source: Internet
Author: User

Foreground HTML code:

<%@ page language= "C #" autoeventwireup= "true" codefile= "Default2.aspx.cs" inherits= "DEFAULT2"%><! DOCTYPE html>

Background C # code:

Using system;using system.collections.generic;using system.linq;using system.web;using System.Web.UI;using System.web.ui.webcontrols;public partial class default2:system.web.ui.page{protected void Page_Load (object sender, E Ventargs e) {if (!            IsPostBack) {Testdatacontext context = new Testdatacontext (); Bind data Source Repeater1.datasource = context.            Car;        Repeater1.databind (); }} protected void button1_click (object sender, EventArgs e) {testdatacontext context = new Testdataconte        XT ();        String name = TextBox1.Text; Determine if the input is not an empty if (name! = "") {//Check auto table fuzzy query contains () find out all the data put into a set var query = Cont Ext.            Car.where (p = p.name.contains (Name)); Turn each keyword into red or mark plus tag//convenience Each of the foreach (Car data in query) {//replace: Replace () replaces the original key word with the tag data. Name = data. Name.replace (Name, "<Mark> "+ name +" </mark> ");            }//bound data source Repeater1.datasource = query;        Repeater1.databind (); } else {//bind data Source Repeater1.datasource = context.            Car;        Repeater1.databind (); }    }}

Page display:

WB tips keywords Fuzzy query keyword color change

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.