Jasinski Technical Wiki


Home Page
All Pages

Quick Search
Advanced Search »

Contributor Links

Create a new Page
File Management
Your Profile

Other Wiki Sections



Extending Built-In Web Controls - ASP.NET

Modified on Fri, Jul 24, 2009, 9:35 AM by Administrator Categorized as ASP·NET Web Forms
{outline|||Step <1> - }


Although you can create a server control within its own project, sometimes you just want to extend a built-in ASP.NET web control for a single website. Here's how.


Create Extender Class

  • Create yourself a new class in the App_Code folder of your website, naming the class whatever you like.
  • Have the class inherit from whatever control you like in the System.Web.UI.WebControls namespace.
  • Be sure to specify a namespace for your class — you'll need it for the web.config file.
  • Add whatever methods and properties you require.

Configure Your Website

  • In the Web.Config file, add the following entry. This allows you to bypass the adding of the <%@ Register %> tag at the top of each page where you want to use the server control.

      <add tagPrefix="tag" namespace="namespace" />

Implement your Control

You can reference the new control in your ASPX code as follows.

  • The tag is the same as the tag you specified in the web.config file
  • The className is simply the name of the class you just created above.

<tag:className runat="server" ... />

ScrewTurn Wiki version Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.