Introduction to custom server controls

The final control

Well this class is so small I'll just show you all of the code at once:

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Guestbook.Engine;
namespace Guestbook
    /// <summary>
    /// Summary description for GuestbookRepeater.
    /// </summary>
    public class GuestbookRepeater : Repeater
        protected override void OnInit(EventArgs e)
            DataSource = XmlEngine.GetGuestbookEntries();

As you can see, no magic here, just a single overridden method that sets a hard coded value as the control's DataSource . DataBind method is also called here. Although there is one little piece of “magic” – the class derives from System.Web.UI.WebControls.Repeater .

Now we're actually finished, but I'd like to show you how you can add these controls to any of your pages...

You might also like...



Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Engineers are all basically high-functioning autistics who have no idea how normal people do stuff.” - Cory Doctorow