⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 search.cs

📁 ASP开发网站的 关于网站的设计和说明 还有SQL的程序 数据库
💻 CS
字号:
namespace ASPNET.StarterKit.Communities {

	using System;
	using System.Web.UI;
	using System.Web.UI.WebControls;
	using ASPNET.StarterKit.Communities;



    //*********************************************************************
    //
    // Search Class
    //
    // Represents the Search page. The Search page can be used
    // to search community content.
    //
    //*********************************************************************
    
	public class Search : SkinnedCommunityControl {
	
		string _skinFileName = "Search_Search.ascx";
        
        TextBox txtSearch;
        RadioButtonList rdlSearchWhere;
        Button btnGo;
		ContentList _contentList;



        //*********************************************************************
        //
        // Search Constructor
        //
        // Calls the base SkinnedCommunityControl constructor
        // and assigns the default page skin.
        //
        //*********************************************************************
        
		public Search() : base() {
			// Assign a default skin file name
			if (SkinFileName == null)
				SkinFileName = _skinFileName;
		}
	

        //*********************************************************************
        //
        // SkinType Property
        //
        // Specifies the skins directory where this page's skin file is located.
        //
        //*********************************************************************

		override protected string SkinType {
			get { return "ContentSkins"; }
		}
        

        //*********************************************************************
        //
        // InitializeSkin Method
        //
        // Retrieves all the controls from the Page Skin
        //
        //*********************************************************************

		override protected void InitializeSkin(Control skin) {
		      // Find Search TextBox
		      txtSearch = (TextBox)GetControl(skin, "txtSearch");
              txtSearch.TextChanged += new EventHandler(btnGo_Click);
		
		      // Find Go button
		      btnGo = (Button)GetControl(skin, "btnGo");
              btnGo.Click += new EventHandler(btnGo_Click);
              		
              // Find the search where radio button list
              rdlSearchWhere = (RadioButtonList)GetControl(skin, "rdlSearchWhere");
      		
		      // Find ContentList Control
              _contentList = (ContentList)GetControl(skin, "ContentList");
		}



        //*********************************************************************
        //
        // OnLoad Method
        //
        // Handles the Page Load event in order to initialize the current page
        // by assigning values to the controls.
        //
        //*********************************************************************

		protected override void OnLoad(EventArgs e) {
		  if (!Page.IsPostBack) {
		      EnsureChildControls();
		      if (Context.Request["search"] != null) {
		          string searchString = Context.Request["search"];
		          txtSearch.Text = searchString;
		          BindResults();
		      }
		  
		  }
		}

	

        //*********************************************************************
        //
        // btnGo_Click Method
        //
        // Raised when the Go button is clicked. Performs a search.
        //
        //*********************************************************************
	
	    void btnGo_Click(Object s, EventArgs e) {
	       BindResults();
	    }
	

        //*********************************************************************
        //
        // BindResults Method
        //
        // Retrieves the list of matching content from the SearchUtility component
        // and binds the content to the Repeater control.
        //
        //*********************************************************************
	
        void BindResults() {
            // Determine where to search
            int sectionID = -1;
            if (Int32.Parse(rdlSearchWhere.SelectedItem.Value) == 0)
                sectionID = objSectionInfo.ID;
            
            // Bind search results to repeater    
            _contentList.DataSource = SearchUtility.GetSearchResults(objUserInfo.Username, sectionID, txtSearch.Text);
            _contentList.DataBind();
        }


	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -