Malaika Consultants LLC

Step3: ASP.NET Web User Controls

by Jane Thomson 19. March 2011 01:05

We will learn about new control which is known as web user controls in step 3. Web User controls are the controls which are created and added to the web pages. To create a web user control on the web page is pretty much similar to creating a control for the desktop applications. The user control is ASP.NET is based in the class System.Web.UI.UserControl.

Adding a Web User Control on a web page is pretty simple. You can add user controls from the user Add Controls Windows of ASP.NET and by default they come with the .ascx extension. Instead of having @page directives, ASP.NET user controls contain @control directive which defines the configuration of the user control. The limitation of Web User Control is that they cannot be used stand alone and user must have to add it into the ASP.NET webpage just like other controls. ASP.NET web user control differs from the traditional web user control in a way that they shall have the elements like html, body or form only on the hosting page.

Add Web User Controls to Page

In order to add ASP.NET web user controls to the page, user must have to register it on hosting page. While registering, user has to denote the.ascx file containing web user control, a tag name and a tag prefix.

Once done with registering the control, user has to add the code for putting the control on the host page. In this case, below line of code is useful.

<uc1:links id="links1" runat="server"/>

Just like other controls on the page, you can see that even web user controls contains the property of runat = “server” which defines its dynamic nature on ASP.NET unlike traditional web user controls. If a web user control has the Web Server Control, you can also code a web user control to handle events requested by other child web user controls.

For Step 4 please click here.


::: | © Malaika Consultants LLC | :::

Malaika Consultants LLC

Malaika Consultants LLC is a custom software development consulting firm located in Cary (Raleigh Durham Research Triangle AKA RTP area ) North Carolina. We offer our expert consulting services in the Microsoft .NET and related technologies. Our mission is to partner with you and ensure the success of your project. We have a team in the USA that will help you with your Information Technology needs and we strive to be truly "Your Information Technology Angels"

We are offering 1 hour of free consulting -- ASP.NET, SQL Server, IIS, anything. Contact us to get your free consulting

Recent Comments