How do I use the URL picker?

G

Guest

I'm creating a custom web control and a few of the properties should be
image URLs. How do you get the system to present the URL picker as an
option when the user is setting the control's properties? (Like the
standard controls do for image URLs...) Thanks.

Jerry
 
S

Steven Cheng[MSFT]

Hi Jerry,

Welcome to the ASPNET newsgroup.

As for how to let our custom webcontrol's string property use the "URL
picker" at design-time(in VS.NET ide), based on my research, we can use the
"EditorAttribute" to apply some certain control editor to our custom
control's string property. There exists some buildin control property
editors in .net framework class library, for example:

UrlEditor, ImageUrlEditor....

Here is simple test control which configure its "Text" propety to use the
"ImageUrlEditor" at design-time in VS.NET ide:

=====================================
[DefaultProperty("Text")]
[ToolboxData("<{0}:TestControl runat=server></{0}:TestControl>")]
public class TestControl : WebControl
{
[Bindable(true)]
[Category("Appearance")]
[DefaultValue("")]
[Localizable(true)]
[ Editor("System.Web.UI.Design.ImageUrlEditor, System.Design,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
typeof(UITypeEditor))]
public string Text
{
get
{
String s = (String)ViewState["Text"];
return ((s == null) ? String.Empty : s);
}

set
{
ViewState["Text"] = value;
}
}
==================================

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top