<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="Default" %>
<%@ Register Src="Control.ascx" TagName="Message" TagPrefix="x" %>
Testing a User Control
The page puts ASP.NET user controls through their paces.
File: Default.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 Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Message1.ForeColor = "blue";
Message1.Text = "Hello world";
}
}
File: Control.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Control.ascx.cs"
Inherits="Default" %>
"><%= Text%>
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 Default : System.Web.UI.UserControl
{
public string ForeColor;
public string Text;
}