Wednesday, 7 August 2013

How to create and use User Control in asp.net - asp.net example || User Controls in ASP.NET

Hi Friends, in this article I will explain about what is
User control? How to create and use User Control in asp.net.

User controls (.ascx pages) allow you to save a part of an
existing ASP.NET page and reuse it in many other ASP.NET pages ex:header ,
footers.

A user control is almost identical to a normal .aspx page, with differences:
the user control has the .ascx extension rather than .aspx, we cannot run the
.ascx page individual and it may not have <HTML>, <Body>, or
<Form> tags.

I explain this with small example.

First of all create one .ascx file.

Right click on project root folder ---Add new item ---
select webusercontrol (.ascx) and name it as menu.ascx.