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