-
Notifications
You must be signed in to change notification settings - Fork 0
/
Search.aspx.cs
43 lines (35 loc) · 1.17 KB
/
Search.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using oragnic.Cms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace oragnic
{
public partial class Search : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void search(object sender, EventArgs e)
{
String path = Server.MapPath("~/App_Data/post_sale.xml");
List<Post> postList = XMLcode.GetListBlogInXML(path);
List<Post> postListsp_noibat = new List<Post>();
String text = Request.Form["search"];
foreach (Post pst in postList)
{
//ToLower() :Chuyển chuỗi sang chữ thường
if (pst.Name.ToLower().IndexOf(text.ToLower()) != -1)
{
postListsp_noibat.Add(pst);
}
}
ListViewsp_search.DataSource = postListsp_noibat;
ListViewsp_search.DataBind();
search_ketqua_h2.InnerText = "Kết quả tìm kiếm sản phẩm: ";
search_ketqua_span.InnerText = text;
}
}
}