Click here to Skip to main content
Licence CPOL
First Posted 27 Feb 2008
Views 41,125
Downloads 668
Bookmarked 61 times

Image Gallery 1.0

By | 29 Feb 2008 | Article
An article on how to create an advanced web custom control for image display.
Prize winner in Competition "Best ASP.NET article of February 2008"

Introduction

Image gallery 1.0 is a custom control with full design time support. This article will give you complete information on creating custom controls, complex properties, inner properties and smart tags, and how to provide design time support in custom controls. This control gives you the solution for showing images like BBC and CNN news websites do. It also provide the auto next (slide show) feature, and some image changing styles.

How to use

To use the Image Gallery 1.0 control on your website, you will need to add the control into the toolbox by right-clicking it, selecting 'Customize Toolbox', selecting the '.NET Framework Components' tab, and then clicking on the Browse button. Navigate to the ImageGallery.dll. This should add it to the toolbox. Then, just drag this control onto the page where you want the control to be.

Image Gallery 1.0 shows you how to add complex properties like GridViews.

<cc1:Gallery ID="Gallery1" runat="server">

    <NavigationItemBarItemStyle BackColor="#5F74A3" Height="20px" Width="20px" />
    <TitleStyle Font-Bold="True" Font-Size="16px" ForeColor="Black" />
    <NavigationItemBarSelectedItemStyle BackColor="#8C9FCA" Height="20px" Width="20px" />
    <NavigationBarStyle HorizontalAlign="Center" />
    <ImageStyle Height="300px" Width="400px" />
    <DescriptionStyle Font-Size="10px" Height="75px" />
    <NavigationItemBarHoverItemStyle BackColor="#8C9FCA" Height="20px" Width="20px" />
    
    <Images>
        <cc1:Image ImageUrl="~/images/p1.jpg" Selected="true" />
        <cc1:Image ImageUrl="~/images/p2.jpg" Selected="false" />
        <cc1:Image ImageUrl="~/images/p3.jpg" Selected="false" />                   
    </Images>
    
</cc1:Gallery>

Details of some properties:

  • AutoNext: is used for automatically showing the next image after a specific time set in the AutoNextAfter property.
  • AutoNextAfter: is the auto-next time, in seconds.
  • DataSource: is used for binding images from a specific data source.
  • DataImageField: is the field in the data source which provides the image URL.
  • DataTitleField: is the field in the data source which provides the image title.
  • DataDescriptionField: is the field in the data source which provides the image description.
  • ShowTitle: is used for the setting the image title visibility.
  • ShowDescription: is used for the setting the image description visibility.
  • ShowNavigationBar: is used for the setting the navigation bar visibility.
  • ImageFolder: is used for setting the path of the image folder from which the user wants to display an image.
  • ImagesExtensions: contains the comma separated list of image extensions.
  • ImageChangeStyle: is used to set the image changing style.

How to add images

User can select or add images in three ways:

  1. Add images to an image collection. The Images property is used for adding images to the control.
  2. Select the path of the folder in which images exist, using the ImageFolder property.
  3. Using a data source

The Images property is used to store the collection of images. The Images property is a collection base; during design time, it will be an open collection editor.

The Images property is an inner property; so, we add a property level metadata attribute [PersistenceMode(PersistenceMode.InnerProperty)].

[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[PersistenceMode(PersistenceMode.InnerProperty)]
[Description("Images")]
public ImageCollection Images
{
    get
    {
        if (_images == null)
            _images = new ImageCollection();
        return _images;
    }
}

The ImageCollection class is inherited from the CollectionBase class and the CollectionBase class is used to create a custom collection.

public class ImageCollection : CollectionBase
{
    public Image this[int index]
    {
        get{ return (Image)this.List[index];}
        set{this.List[index] = value;}
    }
    
    public void Add(Image image)
    {
        image.Index = this.List.Count;
        this.List.Add(image);
    }
    
    public void Insert(int index, Image image)
    {
        this.List.Insert(index, image);
    }
    
    public void Remove(Image image)
    {
        this.List.Remove(image);
    }
    
    public bool Contains(Image image)
    {
        return this.List.Contains(image);
    }

    public int IndexOf(Image image)
    {
        return this.List.IndexOf(image);
    }

    public void CopyTo(Array array, int index)
    {
        this.List.CopyTo(array, index);
    }
}

Smart Tag

This control provides full design-time support. You can also set the properties using a Smart Tag. The user can also apply some pre-defined styles using auto-format. This article explains how to create professional a Smart Tag.

For creating a Smart Tag, create a designer class and inherit it from System.Web.UI.Design.ControlDesigner. The designer class handles the behavior of a control on the design surface. We can override methods of the ControlDesigner class for design-time support. In this article, I will explain only one method, which is used to handle a Smart Tag. For displaying a Smart Tag, we override the ActionLists property of the ControlDesigner class.

class GalleryDesigner : System.Web.UI.Design.ControlDesigner
{ 
    DesignerActionListCollection _actionList = null;
    
    public override DesignerActionListCollection ActionLists
    {
        get
        {
            if (_actionList == null)
            {
                _actionList = new DesignerActionListCollection();
                _actionList.Add( new GalleryActionList(this));
            }                
                           
            return _actionList;
        }
    }
}

ActionLists returns the list of all actions which show on the Smart Tag. In this article, we get this list from GalleryActionList, which is inherited from the System.ComponentModel.Design.DesignerActionList class, and we override its method GetSortedActionItems() as shown below:

class GalleryActionList : System.ComponentModel.Design.DesignerActionList
{
    #region OVERRIDED METHODS

    public override DesignerActionItemCollection GetSortedActionItems()
    {

        DesignerActionItemCollection list = new DesignerActionItemCollection();
        list.Add(new DesignerActionMethodItem(this, "ShowAutoFormat", 
                 "Auto Format...", "Format"));            
        list.Add(new DesignerActionMethodItem(this, "EditImages", 
                 "Images...", "images"));
        list.Add(new DesignerActionPropertyItem("ShowTitle", 
                 "Show Title", "Other"));
        list.Add(new DesignerActionPropertyItem("ShowDescription", 
                 "Show Description", "Other"));

        return list;
    }

    #endregion
}

Points of interest

During the development of this control, I found one major issue which was how to add images from a Smart Tag. I tried to solve it through many ways, but was unable to solve it successfully, because changes from the Smart Tag were not reflecting properly on the page. Finally, I got a solution from a forum. The solution is available in the EditorServiceContext.cs file.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Shakeel Iqbal

Software Developer (Senior)
TEO
Pakistan Pakistan

Member

i have been working in software house as senior software engineer. i have worked on many web and windows projects. My hobbies are to read books and develop my own small utilities.
 

My Blogs
Follow me on Twitter

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 4 Pinmemberlmkdev22:44 30 Nov '11  
GeneralTwo copies of the control on the one page does not increment correctly Pinmembergarethwilliams1:07 7 Oct '10  
Generalfive ***** from me ;) Pinmemberhammad326:07 18 Jan '10  
GeneralRe: five ***** from me ;) PinmemberShakeel Iqbal6:45 18 Jan '10  
Generalclick and pass url Pinmemberjinboh5:11 1 Jan '10  
GeneralRe : Image Starts from 1 not 0 PinmemberMember 7509856:28 2 Dec '09  
GeneralRe : Page Navigation bar Top PinmemberMember 7509854:37 16 Nov '09  
GeneralRe: Re : Page Navigation bar Top PinmemberShakeel Iqbal6:14 17 Nov '09  
QuestionImage Style For Each Different Image? Pinmemberisidat4:28 25 Aug '09  
AnswerRe: Image Style For Each Different Image? PinmemberShakeel Iqbal20:33 26 Aug '09  
QuestionHow can I make the image at the center of the image container? Pinmemberisidat13:32 23 Aug '09  
AnswerRe: How can I make the image at the center of the image container? PinmemberShakeel Iqbal21:36 23 Aug '09  
GeneralRe: How can I make the image at the center of the image container? Pinmemberisidat0:10 24 Aug '09  
QuestionHi, Can you give the Image more effect? PinmemberJLKEngine00816:48 14 Sep '08  
GeneralCITIES/TOWNS IN KASHMIR NAMED MAGRAY PinmemberRABIA ANWER MAGRAY8:15 31 Aug '08  
GeneralMAGRAY- A MARTIAL& A WARRIOR KASHMIRI TRIBE/CASTE/RACE PinmemberRABIA ANWER MAGRAY8:07 31 Aug '08  
MAGRAY A MARTIAL &amp; A WARRIOR KASHMIRI TRIBE:
Also known and spelled as MAGRI, MAGRE &amp; MAGREY. But the correct spelling is MAGRAY. Pleural of MAGRAY is MAGRES.anwerrabia076@gmail.com                                
Magray is a Martial Kashmiri tribe of Rajput origin. Magray sprung from Kashtri-un-Nassal Rajput. Kashtri-un-Nassal Rajput are one of the four classes of Hindus. Kashtri were people of ruling class having responsibility for the defence of the state. Ladhay Magray was the forefather of Magray tribe. Magres accepted Islam at the hand of Syed Ali Hamdani in thirteenth Century. The first person who entered in Kashmir and settled there belonged to Magray tribe thus making Magray tribe, the founders of Kashmir. Magray tribe ruled over Kashmir for seven hundred years. They invited Mughals to enter Kashmir in order to end disturbances in the valley. However, subsequently Mughals were defeated and pushed back by the Magray tribe. Magray tribe is settled all over the world with majority in Kashmir Valley. In spite of being SARDARS of the time, people of Magray tribe felt proud to be called as MAGRAY.  
VILLAGES &amp; TOWNS IN   KASHMIR NAMED MAGRAY:
               1.Magray Village, District Bagh
               2. Magray City, Kuttan, Neelum valley, Muzaffarabad
               3.Magray Hills, Kanchikot, Rawalakot
               4. Magray Abad, Rawalakot
               5. Magray Gali, Lipa Valley, Muzaffarabad
               6. Magray Abad, Athmaqam,Kel road,Neelum Valley
               7. Magray Village,Motarin, khaigala, Rawalakot
               8.Kharl Magrayay,District Bagh
               9 Sardari Magrayan,Neelum Valley Muzaffarabad
               10.Magray Village Marchkot,Abbaspur
               11.Bandian Magray,Abbaspur
MEANINGS OF MAGRAY:
Magray is an ancient word, Magray means, "The Martials", "The Warriors", "Military and war like people". Magray is also spelled as Magrey, Magre and Magri, but the correct spelling is Magray. The plural of Magray is Magres.
HISTORRICAL BOOKS ON MAGRAY TRIBE:
All the historical books on Kashmir contain material on Magray tribe and their role in the history of Kashmir. Few of the historical Books are mentioned here for reference.  
1.   Magray in the Eyes of History By Sajid Latif Magray
2.   Magray A Warrior Kashmiri Tribe   By Abdul Qayyum
3.   Valley of Kashmir   By Sir Walter Lirance
4. Imperial Gazettier of India   Govt of India
5.   Tribes and Castes of Kashmir   By Muhammad Din Folk
6   .Castes and Tribes of Poonch By Muhammad Din Folk
7. History of Kasmir By Khawaja Azamey
8.   History of Kashmir By Muhammad Hassan
9.   History Kabeer Kashmir By Haji M.Mohiudin  
10.Raj Tarangi By Pandit Kahlan
11. Tareekh-e-Kashmir By Professors Nazir Ahmed Tashna
12. Kashmir in the Era of Muslim empires By Ghulam Hassan Khoyami
13. Tareekh-e- Malkan By Dr Sadiq Malik
14. Jalwa-e-Kashmir By Dr Sabir Afaqi
15   Baharistan-e-Shahi   A Chronocle Mediaeval of Kashmir
16.   Magray- The Martials and Warriors of Kashmir By Sajiad Latif Magray
17. Tareekh-e-Kashmir,Islamia By Dr Sabir Afaqi
18. Tareekh-e-Azmi By   M.Azam
19. Tribal geography of India Jamu and Kashmir By Muhammad   Bashir Magray
20. A New History of India and PakistanBy Quyyam Abdul
MAGRAY VILLAGES IN KASHMIR:
1.MAGRAY   VILLAGE   MOTARIN, RAWALKOT:This is a village comprising of about 400 houses, exclusively of the Magray Tribe. Road leading from Rawalkot to Tatrinote crossing point passes from this village. Few personalities of the village are:-
a.         Muhammad Din Magray
b.         Subedar   Muhammad Latif Magray
c.         Sajjad Latif Magray
d.         Rasheed Magray
e.         Yaqoob Magray
f.         Manzoor Magray
g.         Sadique Magray
h.         Dilpazir Magray
i.         Muhammad Aamir Magray
j.         Bashir Magray
k.         Qayyum Magray
l.         Yaseen Magray
m.         Imran Yaseen margay
n.         Shafi Magray
o.         Akram Magray
p.         Rafique Magray
q.         Sajjad Magray
r.         Muhammad Javed Magray
s.         Kabir Magray
t.         Kamran Magray
2.MAGRAY   HILLS   KANCHIKOT:This is a big village which starts from the Magray Market on Ali Sajad Road and goes to the top of Tolipeer, a prominent Hill top of Kashmir. Few personalities of the Magray Hills are:-
a.         Haji Aqal Hussain Magray
b.         Tariq Magray
c.         Ghulam Nabi Magray
d.         Gulzar Magray
e.         Havildar Yaseen margay
f.         Subedar Rafique Magray
g.         Hanif Magray
h.         Havildar Azam Magray
i.         Muhammad Ashraf Magray
j.         Kala Khan Magray
k.         Hakim din Magray
l.         Capt Yaqoob Magray
m.      Asghar Magray
n.      Sadique Magray
o.      Haji Abdullah Magr
3.MAGRAY   ABAD   RAWALAKOT:This is a small town in Rawalakot valley on Banjora Road in Barmang. Few of the personalities of the area are:-
a.         Abdul Majeed Magray
b.         Muhammad Arif Magray
c.         Muhammad Razaque Magray
d.         Muhammad Imtiaz Magray
e.         Muhammad javed Magray
f.         Muhammad Shoukat Magray
g.         Muhammad Riaz Magray
h.         Muhammad Ishaque Magray
i.         Muhammad Shakeel Magray
j.         Muhammad Jahangir Magray
k.         Muhammad Khurshid Magray
l.         Muhammad yaseen Magray
4.MAGRAY   VILLAGE   BAGH:
This village start from Magray city Lower Bela and extends tol the prominent Hill top of Kashmir Lasdana. This village comprises of 600 houses 100% of the Magray tribe people. Few personalities of the Magrtay village are:-
a.         Dr Mir Akbar Magray
b.         Gohar Magray
c.         Abdul Hameed Magray
d.         Fazal Gohar Magray
e.         Aslam Magray
f.         Hayat margay
g.         Liaqat Ali Magray
h.         Ghulam Nabi
i.         Wali Noor Magray
j.         Sakhi Muhammad Magray
k.         Haseeb Magray
5.KHARL   MAGRAYAN:
It is a small area in District Bagh, people of Magray tribe are settled here. Few personalities of   the area are:-
a.         Muhammad Ashraf Magray
b.         Muhammad Farooq Magray
c.         Abdul Hameed Magray
d.         Gulfraz Magray
e.         Akram Magray
f.         Haji Hakeek Magray
g.         Muhammad Khurshid Magray
h.         Fazal Hussain Magray
i.         Shakeel Ahmed Magray
6.MAGRAY   GALI   LIPA:
A prominent Hilltop of Kashmir in Lipa valley. Few personalities of the area are lmentioned here:-
a.         Capt Ghulam Hussain Magray
b.         Ghulam Rasool Magray
c.         Pervaiz Magray
d.         Prof Kosar Magray
7.MAGRAY CITY KUTTAN:
Few notables of the area are:-
a.         Mangta Magray
b.         Shahzaman Magray
c.         Arshad Magray
d.         Shahzaman Magray
e.         Ali Akbar Magray
f.         Asad Magray
g.         Matloob Magray
h.         Attique Magray
i.         Oamer Zaman Magray
j.         Amjid Magray
8.MAGRAY   ABAD   ATHMAQAM:
A SMALL TOWN IN Neelum valley on Kel Road near Athmaqam. Few personalities of the area are:-
a.         Muhammad Mustafa Magray
b.         Muhammad Khurshid Magray
c.         Muhammad Subhan Magray
d.         Shakeel Magray
e.         Ashraf Magray
f.         Mushtaq Magray
g.         Ghulam Hussain Magray
h.         Abid Magray
9.SARDARI   MAGRAYAN – REMOTE   AREA   OF   NEELUM   VALLEY:
10.MAGRAY   VILLAGE   MARCHKOT:
This is the larges village of Abbaspur town comprising of more than 1000 houses exclusively of the Magray Tibe. Few personalities of the village are:-
a.         Sher Akbar Magray
b.         Havildar Karim Magray
c.         Muhammad Sharif Magray
d.         Muhammad Afsar Magray
e.         Muhammad Rasheed Magray
f.         Manzoor Magray
g.         Muhammad Rafique Magray
h.         Muhammad Raheem Magray
i.         Saleem Magray
j.         Ali Akbar Magray
k.         Muhammad Azeem Magray
l.         Muhammad Yaqoob Magray
m.         Mubashar Salam Din Magray
n.         Sadique Magray
o.         Hameed Magray
p.         Kutab Dinb Magray
11.BANDIAN   MAGRAY:This is a remote village of Abbaspur town comprising of more than 500 houses   entirely of the Magray tribe. Few personalities of Bandian Magray are:-
a.         Muhammad Arif Magray
b.         Mir Akbar Magray
c.         Muhammad Bashir Magray
d.         Muhammad Ashraf Magray
e.         Muhammad Nazir Magray
f.         Sakhi Muhammad Magray
g.         Jalal Din Magray
h.         Muhammad Saddique Magray
i.         Shoukat Magray
j.         Rasheed Magray
HISTORY OF MAGRAY TRIBE
TWO BOOKS “MAGRAY THE MARTIALS AND WARRIORS OF KASHMIR”AND “MAGRAY IN THE EYES OF HISTORY”HAVE BEEN WRITTEN BY SAJJAD LATIF MAGRAY .LAUNCHING CEREMONY   OF THESE BOOKS WAS HELD ON 1st FEB 08 AT PRESS CLUB RAWALPINDI   AND WAS ATTENDED BY THE PRIME MINISTER OF AJ&amp;K AND HIS CABINET MEMBERS.TITLE OF BOOKS ARE WRITTEN BY THE FOL KNOWN SCHALOURS AND HISTORIANS OF THE COUNTRY.
1. DR. M. ASHRAF QURESHI – CHAIRMAN DEPTT OF            KASHMIRIYAT PUNJAB UNIVERISTY LAHORE.
2. DR.SABIR AFAQI            – AUTHOR &amp; HISTORIAN
3. DR.M.SADIQ MALIK      -AUTHOR &amp; HISTORIAN
ORGANIZATIONS OF MAGRAY TRIB:
1         MAGRAY SUPREME   COUNCIL:   IS THE
SUPREME BODY OF MAGRAY TRIBE,
EMPOWERED TO TAKE ALL SORT OF POLITICAL AND SOCIO ECONOMICAL DECISIONS IN THE BEST   INTEREST OF MAGRAY TRIBE.
2.         MAGRAY EDUCATIONAL SOCIETY (REGD): PROMOTES EDUCATIONAL         ACTIVITIES IN THE TRIBE AND EVEN OUTSIDE THE MAGRAY TRIBE.
3. MAGRAY TANZEEM (REGD): WAS ESTABLISHED TO PROVIDE A   PLATFORM AND ORGANIZE THE MAGRAY TRIBE.
4.         MAGRAY WELFARE TRUST: LOOKS AFTER THE ILL, POOR AND NEEDY PEOPLE OF THE KASHMIR IN PARTICULAR AND PAKISTAN IN GENERAL.
GeneralHelp is required! PinmemberSobia Saeed Magray19:16 9 Jun '08  
Generaldatasource PinmemberTaTes13:01 7 Jun '08  
Generalnice work PinmemberTaTes2:38 4 Jun '08  
GeneralRe: nice work PinmemberShakeel Iqbal2:44 4 Jun '08  
GeneralNice Article PinmemberAkajasimafat7:21 3 Apr '08  
GeneralExcellent work PinmemberAfaak6:49 24 Mar '08  
GeneralNice control but AutoNext doesn´t work PinmemberGlauter7:21 18 Mar '08  
GeneralRe: Nice control but AutoNext doesn´t work PinmemberShakeel Iqbal19:06 18 Mar '08  
GeneralDoesn't work PinmemberRogic2:17 1 Mar '08  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120604.1 | Last Updated 1 Mar 2008
Article Copyright 2008 by Shakeel Iqbal
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid