November 03, 2008

Creating a Simple User Control


User controls allow you to save a part of an existing ASP.NET page and reuse it in many other ASP.NET pages. A user control is almost identical to a normal .aspx page, with two differences: the user control has the .ascx extension rather than .aspx, and it may not have

<HTML>, <Body>, or <Form> tags.


The simplest user control is one that displays HTML only(.ascx file)

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl1.ascx.cs" Inherits="MyUserControl.WebUserControl1" %>







CopyRight 2008 Ramp Infotech, Inc.
Support at http://www.rampgroup.com


To see it work add this in the .aspx file as:
<%@ Register tagprefix="ramp" TagName="CopyRight" src="CopyRight.ascx" %>


This registers the control with our page and we can use it like






0 comments: