using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

/* =====================================================================

  File:      _Header.ascx.cs for Adventure Works Cycles Storefront Sample
  Summary:   Master page visual component which should appear at the top of most web pages.
			 Provides basic functionality navigation.
  Date:	     June 16, 2003

---------------------------------------------------------------------

  This file is part of the Microsoft SQL Server Code Samples.
  Copyright (C) Microsoft Corporation.  All rights reserved.

This source code is intended only as a supplement to Microsoft
Development Tools and/or on-line documentation.  See these other
materials for detailed information regarding Microsoft code samples.

THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.

======================================================= */

namespace Microsoft.Samples.SqlServer 
{

    public partial class HeaderControl : System.Web.UI.UserControl
    {
    
//         protected HeaderControl() {
//             this.Init += new System.EventHandler(Page_Init);
//         }

        private void Page_Init(object sender, EventArgs e) {
            //
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            //
            InitializeComponent();
        }

		private void Page_Load(object sender, System.EventArgs e)
		{
			if (this.IsPostBack && (!txtSearch.Text.Equals(string.Empty)))
			{
				SearchButton_ServerClick(sender, null);
			}
		}

		public void CommandBtn_Click(Object sender, CommandEventArgs e)
		{
			switch (e.CommandName)
			{
				//TODO: Encapsulate the redirect in a better named method.

				case "Search": if (!txtSearch.Text.Equals(string.Empty))
						Response.Redirect("SearchResults.aspx?txtSearch=" +
										  txtSearch.Text);

					break;
			}
		}

		#region Web Form Designer generated code
        ///		Required method for Designer support - do not modify
        ///		the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent() {
		}
		//TODO: Encapsulate the redirect in a better named method.
		void SearchButton_ServerClick(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			Response.Redirect("SearchResults.aspx?txtSearch=" + txtSearch.Text);
		}

		#endregion

    }
}