protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { (Master.FindControl("masterTextBox") as TextBox).Visible = false; (Master.FindControl("masterLabel") as Label).Visible = false; (Master.FindControl("masterButton") as Button).Visible = false; if (Request.QueryString["page_request"] != null && Request.QueryString["search_type"] != null && Request.QueryString["search_content"] != null) { string str = Request.QueryString["search_content"]; if (str.Equals(String.Empty)) { this.showFalseMessage("输入内容不能为空!"); return; } if (str.Length < minSearchSize) { this.showFalseMessage("输入内容太短!"); return; } if (str.Length > maxSearchSize) { this.showFalseMessage("输入内容太长!"); return; } TextBox1.Text = str; string pageRequestedString = Request.QueryString["page_request"]; if (pageRequestedString.Equals(String.Empty)) { this.showFalseMessage("页码输入不正确!"); return; } int pageRequested = Int32.Parse(pageRequestedString); if (pageRequested < 1) { this.showFalseMessage("页码输入不正确!"); return; } SearchType type = (SearchType)Int32.Parse(Request.QueryString["search_type"]); DropDownList1.SelectedIndex = (int)type; NewsDAO dao = new NewsDAO(); int pageSize = 0; DataSet ds = new DataSet(); switch (type) { case SearchType.Article: pageSize = dao.GetNewsSizeByArticle(str, pageDefaultSize); ds = dao.SearchNewsByArticle(str, pageDefaultSize, pageRequested); initList(ds, pageSize); break; case SearchType.Title: pageSize = dao.GetNewsSizeByTitle(str, pageDefaultSize); ds = dao.SearchNewsByTitle(str, pageDefaultSize, pageRequested); initList(ds, pageSize); break; case SearchType.TitleAndArticle: pageSize = dao.GetNewsSizeByTitleAndArticle(str, pageDefaultSize); ds = dao.SearchNewsByTitleAndArticle(str, pageDefaultSize, pageRequested); initList(ds, pageSize); break; } } } }