LightBox can be populated through datasource control with just a few lines of markup. Here is a simple example:
<
telerik:RadLightBox
ID
=
"RadLightBox1"
runat
=
"server"
DataSourceID
=
"SqlDataSource1"
DataImageUrlField
=
"ImageUrl"
DataTitleField
=
"ImageName"
DataDescriptionField
=
"ImageInfo"
>
</
telerik:RadLightBox
>
Similar to other controls from the RadControls suite, LightBox has an Items collection. You can manage the collection in different ways:
Below you can find a simple example of how you can create a new item and then add it to the collection.
RadLightBoxItem newItem =
new
RadLightBoxItem();
newItem.Description =
"My Description"
;
newItem.Title =
"My Title"
;
newItem.NavigateUrl =
"http://myurl.url"
;
newItem.Width = Unit.Pixel(400);
newItem.Height = Unit.Pixel(300);
RadLightBox1.Items.Add(newItem);
I’m sure when you first read about the LightBox features you will make a direct parallel to the Telerik’s ASP.NET Window control. So, are these two controls interchangeable? Yes and no. There is an important keyword in the name of the LightBox – “Light”. It is designed to be simple and fast so it is not a Window replacement.
We’d like to hear your opinion on the LightBox control. Do you have any suggestions for the future versions? Or maybe you would like something to be improved? Please don’t hesitate to share your feedback in the comments section below.
Daniel Peichev is Software Developer at one of Telerik's ASP.NET AJAX teams, where he primarily works on exporting functionality for RadGrid and RadTreeList. Daniel is interested in ASP.NET, Javascript, CSS and the cutting edge Microsoft technologies and products.