My ASP knowledge base

Archive for the ‘designer’ Category

Source code custom server control

Posted by Jan on July 6, 2007

The article about the custom grid control is finished. The post contains links to multiple page explaining the control and the source code has been added (with an example how to use the control).

Regards, Jan

Posted in GridView, asp, compositecontrol, custom control, custom server control, designer, smart tags | 1 Comment »

Custom Server Control: build your own simple GridView

Posted by Jan on June 29, 2007

“This article consists of several pages describing the definition of a custom grid control. You can create your own controls in two ways:

  • User Controls (ascx-extention): a small part of a page that will be reused in your web pages.
  • Custom Server Controls: classes that will generate HTML. Custom Server Controls are compiled into DLL assemblies.

This example describes a Custom Server Control. This gives you total control over the HTML and makes it possible to add the control to your toolbox.

If you are interested in User Controls, see the following pages for more information:
http://www.15seconds.com/issue/020319.htm
http://quickstarts.asp.net/QuickStartv20/aspnet/doc/ctrlref/userctrl/default.aspx

The custom server control described in this article, is a simple databound grid. Easy to add to your web pages, for those cases where you do not need the extended features of the VS2005’s GridView. And you can modify this control to you own wishes.

This custom grid control is not a templated control. If you are interested in templated custom server controls, please see http://samples.gotdotnet.com/quickstart/aspplus/doc/webctrlauthoring.aspx for more information.

The custom grid control looks like this:

Custom Grid Control

You can add the control by adding a reference in your web page and define the grid’s parameters:

<%@ Register Assembly=”WITControlsLibrary” Namespace=”WITControlsLibrary” TagPrefix=”wit” %>

<wit:WITGrid ID=”WITGridExample” runat=”server”
    DataSourceID=”AccessDataSource1″
    DataKeyName=”participantID”
    ShowDeleteColumn=”True”
    ShowEditColumn=”True”
    ShowOrderColumn=”True”
    HighLightSelectedRow=”true”
    HighLightCssClass=”GridView-Highlight”
    EmptyGridCssClass=”GridView-Empty”
    NoRecordsText=”No records where found.”
    EnableViewState=”False”
    OnRowDataBound=”gridExample_OnRowDataBound”
    OnRowCommand=”gridExample_OnRowCommand”>
    <wit:BoundField CssClass=”grid-column-max” DataField=”participantName” HeaderText=”Name” />
    <wit:BoundField CssClass=”grid-column-medium” DataField=”participantEMail” HeaderText=”E-mail” />
    <wit:CheckBoxField CssClass=”grid-column-medium” DataField=”participantLocked” HeaderText=”Locked” />
</
wit:WITGrid>

The article is split up into different pages in order to avoid one very lengthy page. Click on one of the following items for more info, or click Next Page >> 

I hope these articles will help you further in building your own grid.

Regards, Jan

  Next Page >>

Posted in GridView, asp, compositecontrol, custom control, custom server control, designer, smart tags | 3 Comments »