Subject: Composite Controls
Posted By: origjones Post Date: 8/31/2006 8:45:10 AM
Hi all.

I'm in the process of creating a composite control using C# and Visual Studio Prof 2005. The control takes an Image Url as one of its properties and this is defined in the component as:

//snippet of code

private String _FirstImageURL;

[
Category("Images"),
Description("The URL of the Image - e.g ~/images/first.gif"),
Browsable(true)
]
public String FirstImageURL
{
    get { return _FirstImageURL; }
    set { _FirstImageURL = value; }
}

//end code snippet


However, this doesn't give the desired effect when the component is being used in a project. Where the built in ASP:Image component has a button in the properties to allow the programmer to browse for the image within the current project, mine is just a normal text box.

I have tried many different ideas including changing the type from String to Image in the component code.

Does anyone have any ideas of how I can achieve this browsing option in the property of my component?

Thanks in advance,

Orig.

(p.s. please let me know if you need me to explain it better, I realise I might not be explaining this very well!)
Reply By: Imar Reply Date: 8/31/2006 9:41:42 AM
Hi there,

Try adding an Editor attribute like this:
[EditorAttribute(typeof(System.Web.UI.Design.ImageUrlEditor), typeof(UITypeEditor))]
public string ImageUrl
{
    get
    {
        return imgUrl;
    }
    set
    {
        imgUrl= value;
    }
}
Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
Reply By: origjones Reply Date: 8/31/2006 9:58:43 AM
Hi Imar.

Thankyou for your help, it worked perfectly,

Orig.

Go to topic 49124

Return to index page 188
Return to index page 187
Return to index page 186
Return to index page 185
Return to index page 184
Return to index page 183
Return to index page 182
Return to index page 181
Return to index page 180
Return to index page 179