Custom Controls ASP.Net Tutorial

File: Control.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Control.ascx.cs" Inherits="LinkMenu" %>

  Products:
      NavigateUrl="MenuHost.aspx?product=Books">Books
  
      NavigateUrl="MenuHost.aspx?product=Toys">Toys
  
      NavigateUrl="MenuHost.aspx?product=Sports">Sports
  
      NavigateUrl="MenuHost.aspx?product=Furniture">Furniture
  

File: Control.ascx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class LinkMenu : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
}
File: MenuHost.aspx
<%@ Page Language="C#" AutoEventWireup="true"
    CodeFile="MenuHost.aspx.cs" Inherits="MenuHost"%>
<%@ Register TagPrefix="rntsoft" TagName="LinkMenu" Src="Control.ascx" %>



    Menu Host


    
    

        
            
                
                    
                
                
                      
                
            
        
    

    


File: MenuHost.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class MenuHost : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Params["product"] != null)
        {
            lblSelection.Text = "You chose: ";
            lblSelection.Text += Request.Params["product"];
        }
    }
}