Best Windows Hosting

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Monday, 9 April 2012

What is an ASP.NET User Control?

Posted on 18:58 by Unknown
An ASP.NET user control is a group of one or more server controls or static HTML elements that encapsulate a piece of functionality. A user control could simply be an extension of the functionality of an existing server control. Its extension is .ascx.

A user control typically resides on a page with other elements. This breakup of functionality could be the basis of an entire application built with independent and reusable user controls. The controls could then be dynamically loaded into different areas of the page.

User Control vs. Other Controls:

One source of confusion when working with ASP.NET knows the difference between the many different types of controls.

For Example:  An ASP.NET control is a server-side component that is shipped with .NET Framework. A server control is a compiled DLL file and cannot be edited. It can, however, be manipulated through its public properties at design time or runtime.

User control will consist of previously built server controls. It has an interface that can be completely edited and changed. It can be manipulated at design-time and runtime via properties that you are responsible for creating.

 Advantages:

1. Reuse of same code.
2. Helps in fragment caching.

 Difference between Web page and User controls:

1. Web pages have directive <%@ Page %> while user controls have directive <%@ Control %>
2. Web pages have extension .aspx while user controls have extension .ascx.
3. User controls cannot be directly used.

Page and User Control classes have been derived from the same class. So, both have almost same properties.

Hierarchy: Object --> Control --> TemplateControl --> Page and UserControl

To include a user control in your aspx page, just write Register directive like:

<%Register TagPrefix="cr" TagName="Footer" src="Footer.ascx"%>

Web user controls can be loaded dynamically using LoadControl method provided by Page class.

Types: Independent and Integrated

Independent: These are user controls which contain static HTML which can be included on the page and they have nothing to do with the logic of the page.

Integrated: It deals with the functionality of the page in which it is included.

How to create integrated user controls?

Suppose there is a user control which has one textbox which asks for username and another textbox asks for password and a button named submit. Now we will create two EVENTS, one sucessfulLogin and another unsucessfulLogin and button click event. When button is clicked and username/password is correct, we will raise sucessfulLogin event and else unsucessfulLogin event.

Now the hosting page will create event handler for these events and can do whatever it wants to do with those events.
Email ThisBlogThis!Share to XShare to Facebook
Posted in DOTNET | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • 13 Things to keep in mind before using DLL in Delphi
    Keep in mind the following tips when writing your DLL: 1. Make sure you use the proper calling convention (C or stdcall). 2. Know the correc...
  • How to use TADOTable in Delphi XE2?
    Following is the code snippet which will show you how to use TADOTable in Delphi XE2? procedure TClass1.GetDataFromADOTable; begin   try    ...
  • How to use FindComponent function in Delphi XE2?
    Following is the code snippet which will show you how to use FindComponent in Delphi XE2? procedure TClass1.UseFindComponent(FieldName : str...
  • Online Finance Degrees
    There is a great demand for professionals with profound knowledge of finance and accounting in most of the reputed banks and financial insti...
  • How to grab the recruiter’s attention with your resume?
    Did you know that the average recruiter spends about 8 to 10 seconds glancing at your resume before s/he moves on to the next? So, whether y...
  • 5 ways to handle workload at your workplace
    With bigger workloads, tighter deadlines and more pressure, the temptation to pack in as many tasks as possible is hard to resist. But juggl...
  • Online Marketing Degrees
    Because global competition has become so intense, it should come as no surprise that companies invest heavily in their marketing and promoti...
  • Oracle Streams: An Overview
    Oracle Streams enables information sharing. Each unit of shared information is called a message. The stream can propagate information within...
  • Frameset, Frame and IFrame Elements in HTML
    Frame Element With frames, you can display more than one HTML document in the same browser window. Each HTML document is called a frame, and...
  • 5 Tips to enjoy your workplace
    Many people dislike getting up everyday and trudge to office. This is surprising, especially when we spend more than one-third of our day at...

Categories

  • AJAX
  • C++
  • CSS
  • Delphi
  • DOTNET
  • HTML
  • Javascript
  • jQuery
  • Management
  • Online Degrees
  • Oracle
  • Others
  • Phonegap
  • PHP
  • Unix
  • XML

Blog Archive

  • ▼  2012 (155)
    • ►  September (64)
    • ►  August (11)
    • ►  July (4)
    • ►  June (3)
    • ►  May (25)
    • ▼  April (48)
      • DOM Events: Mouse Events, Keyboard Events, Form Ev...
      • What is DOM (Document Object Model): Tree and Node...
      • DocType: Strict, Transitional and Frameset
      • How the ASP.NET authentication process works?
      • Response.Redirect vs Server.Transfer: What to use ...
      • GET vs POST: Which one is better? A 10 point compa...
      • HTTP vs HTTPS: Similarities and Differences
      • How IIS processes ASP.NET request?
      • AutoEventWireup in ASP.NET: Why my ASP.NET events ...
      • Web Farms in ASP.NET: Advantages and Issues
      • Cautions while dropping a tablespace
      • 12 Point Comparision between FTP and HTTP Protocol...
      • Dataset, Dataview, Datatable and common operations...
      • Client Side State Management in ASP.NET
      • Difference between page_init, page_load and page_p...
      • Database FLASHBACK mode: Overview
      • Database ARCHIVELOG mode: Overview
      • Hash Collision Attacks in .NET
      • ADO.NET: A quick revision
      • What is SQL Injection?
      • What is ASP.NET AJAX?
      • What is DLL HELL?
      • DIV vs TABLE tag: Which one to use?
      • Exception Handling in ASP.NET
      • Business Intelligence (BI): Data Warehouse, Data M...
      • UDDI: Universal Description, Discovery and Integra...
      • Web Services: Exposing and Consuming
      • Web Service Description Language
      • Simple Object Access Protocol
      • Caching in ASP.NET
      • Partial Classes in ASP.NET
      • Difference between DLL and EXE Files
      • What is an ASP.NET User Control?
      • Page Directive in ASP.NET
      • DOTNET Framework: CLR, CTS and CLS
      • What is Tethering and Hotspot?
      • Preventing Caching in AJAX URLs
      • What is web.config file? What is the significance ...
      • HTML vs XHTML vs DHTML
      • AJAX - A quick revision
      • Web Server vs Application Server vs Database Server
      • Difference Between ASP.NET Server Controls and HTM...
      • web.config vs app.config vs machine.config
      • Assemblies in .NET Framework
      • Silver Bullets for Testing
      • Unix Commands which should be on tips of each deve...
      • Basics of IBM Websphere MQ (Part 1)
      • What is Garbage Collector? How and when does it run?
Powered by Blogger.

About Me

Unknown
View my complete profile