1
Reply

How can we create custom controls in asp.net

Somesh Nag

Somesh Nag

17y
4.5k
0
Reply

    In the Visual Studio There is option of creating Web Custom Control.

    Here i m giving one very basic example which is msdn.

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

    namespace CustomControls
    {
          public class FirstControl : Control
          {
                private String message = "Hello";

                public virtual String Message
                {
                      get
                      {
                            return message;
                      }
                      set
                      {
                            message = value;
                      }
                }

                protected override void Render( HtmlTextWriter writer)
                {
                writer.Write(" "
                            + this.Message + "
    " + "The time on the server is " + System.DateTime.Now.ToLongTimeString()
                            + "
    ");

                }

          }
    }

    17y
    0