Data Bound for the ASP.NET Image Rotation control

In this article I will describe how I made the SharpRotator data boundable.

I thought that making a control data bindable was easier. Well afterwards it looks easy, but without seeing it before I think you should never come up with something like this. You can always bind a control by setting a property (object) to one of the supported datasources. But I wanted the data bound designer on my control. The data bound designer is used when you want to set the DataSource, DataMember and DataFields in design time.

I based my develop on the following articles:

I just want to explain in this article the highlines of the databounding because all the details you can find in the articles above.

For data binding support on a control in design time we to create a designer control.
Create a Designer class which inherits from the ControlDesigner class and the IDataSourceProvider interface.

public class DataSourceDesigner: ControlDesigner,IDataSourceProvider {
}
 
Your control must be aware of the designer class so we add the Designer attribute to your webcontrol class like this:
 
[ToolboxBitmap(typeof(SharpRotator), "srIcon.bmp"),
    DefaultProperty(
"DataSource"),
    ToolboxData("<{0}:SharpRotator runat=server>"),
    ParseChildren(
true, "Items"
),
    Designer(
typeof(com.dotnet6.Design.DataSourceDesigner))]
 
Maybe a short explaination of the other attributes:
  • ToolboxBitmap: You use this attribute if you want that containers, as Visual Studio .NET Form Designer, can display the control as a bitmap. My srIcon.bmp is a "Embedded Resource" "Build Action" in my properties window.
  • DefaultProperty: When the control is dropped on a Webform, in design time, the cursor will automatically be focused on the DataSource property.
  • ToolboxData:  Specifies the default tag generated for a custom control when it is dragged from a toolbox in a tool such as Visual Studio.
  • ParseChildren: One of my design time properties is a collection (based on a class). The items within the collection will be added to the generated default tag as child tags instead of attributes on the default tag.

I will explain the rest of he data binding this week.

Published Friday, January 21, 2005 8:58 AM by admin

Comments

# ASP.NET Image Rotation control

Monday, January 24, 2005 2:26 PM by TrackBack
On a lot of commercial websites you can find on the main page something like

# ASP.NET Image Rotation control

Sunday, May 21, 2006 1:11 AM by Wesley Walraeve
On a lot of commercial websites you can find on the main page something like &quot;products in the picture&quot; or &quot;star products&quot;.
Well I also needed something like this for the website I'm working on. A server ASP.NET webcontrol where you

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above:
Powered by Community Server (Non-Commercial Edition), by Telligent Systems