Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 31st, 2006, 08:45 AM
Registered User
 
Join Date: Aug 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Composite Controls

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!)
 
Old August 31st, 2006, 09:41 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Try adding an Editor attribute like this:
Code:
[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.
 
Old August 31st, 2006, 09:58 AM
Registered User
 
Join Date: Aug 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar.

Thankyou for your help, it worked perfectly,

Orig.





Similar Threads
Thread Thread Starter Forum Replies Last Post
AssociateControlID problem with Composite Controls ctt BOOK: Professional ASP.NET 2.0 Server Control and Component Development ISBN: 978-0-471-79350-2 0 May 12th, 2008 11:06 AM
PLEASE HELP - Composite Control brettk_1 ASP.NET 1.0 and 1.1 Professional 0 August 3rd, 2005 06:22 AM
Composite Control bmains .NET Framework 2.0 0 July 25th, 2005 12:57 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.