12-Apr-04 (Created: 12-Apr-04) | More in 'CS-dotnet'

A web page and a .net control

A web page and a .net control


(%@ Register TagPrefix="Custom" Namespace="CustomControls" Assembly = "CustomControls" %)
(html)
   (body)   
      (form  runat=server)          
          Here is a custom ASP.NET server control.(br)(br)
          (Custom:FirstControl Message= "This control tells time. "  runat=server/) 
       (br)                               
      (/form)
   (/body)
(/html)

Commentary

Invoke a class called CustomControls.FirstControl. Set its public property called "Message" to the specified value. Call its render method. Place the output of the render method in the html page.

Class definition


using System;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CustomControls
{
      public class FirstControl : Control
      {
            public String message = "Hello";
            protected override void Render( HtmlTextWriter writer)
            {
            }
      }
}