Server Control Samples

Server Control Samples

.NET Framework 1.1

The following table lists simple samples that show how to perform server control authoring tasks.

Authoring a simple server controlDeveloping a Simple ASP.NET Server Control
Exposing properties from a controlCustom Property Sample
Rendering a server controlRendering a Server Control Samples
Processing postback dataPostback Data Processing Sample
Exposing an eventDefining an Event
Capturing a postback eventPostback Event Sample
Bubbling an eventEvent Bubbling Control Sample
Generating client-side script for postbackPostback Using Client-Side Script Sample
Using a hidden variable for capturing client-side changesPersisting Client-Side Changes in a non-Form Control
Developing a composite controlComposite Server Control Sample
Using rendering instead of control compositionComposition vs. Rendering
Developing a templated controlTemplated Control Sample
Governing control parsing with ParseChildrenAttributeParseChildrenAttribute Sample
Creating a custom control builderCustom Control Builder Sample

The following table lists more complex samples (similar to those that ship with the SDK).

Complex Control Sample
Templated data-bound controlTemplated Data-Bound Control Sample
Validator controlValidator Control Samples

For a sample of a designer for the templated data-bound control, see Web Forms Templated Data-Bound Control Designer.

Building the Samples

The instructions for building the validator samples are described in Validator Control Samples. Instructions for building other samples in the preceding tables are in the following list.

To build the samples

  1. Create an Internet Information Services (IIS) virtual rooted directory (named Samples in this discussion).
  2. Create a subdirectory named bin under the virtual rooted directory (for example, Samples\bin). The bin directory contains assemblies (compiled .dll files) that are local to your ASP.NET application. You can create subdirectories under your virtual rooted directory (for example Samples\EventControls, Samples\DataBoundControls, and so on). However, you must create only one bin directory and it must be directly under the virtual rooted directory (Samples\bin).
  3. Copy the ASP.NET pages (such as .aspx, .ascx, .asax, and .asmx) and source files (such as .cs or .vb) to the virtual rooted directory. If you do not want a user to browse to source code in a deployment scenario, you can copy the source files (.cs or .vb) to a separate directory not under the virtual root. The ASP.NET pages, however, must be placed in the virtual rooted directory (Samples) or one of its subdirectories (Samples\DataBoundControls).
  4. From the virtual rooted directory (or the directory that contains the .cs or .vb source files), execute the following command. If the command is executed from a directory that is not the virtual rooted directory, you will have to supply the path to the \bin directory.
    csc /t:library /out:./bin/CustomControls.dll /r:System.dll /r:System.web.dll /r:System.Drawing.dll *.cs
    [Visual Basic]
    vbc /t:library /out:./bin/CustomControls.dll /r:System.dll /r:System.web.dll /r:System.drawing.dll
     /r:System.Data.dll *.vb
    Note   The assembly that is generated by the above command must be named
    because the assembly name
    is used in the Register page directive on the sample .aspx pages.
  5. Request a sample .aspx page in your browser by entering one the following commands in the address bar.




    Note   You can build the sample incrementally by copying only the files you are interested in and executing the build command in step 4. When you want to add more samples, copy the additional ASP.NET pages and source files to the appropriate directories and reexecute the build command in step 4.

For additional information about deploying ASP.NET applications see the ASP.NET QuickStart --> Deployment.

See Also

Developing ASP.NET Server Controls

© 2016 Microsoft