I am developing a custom server control, that will expose a property for specifying the image path. This property is called 'ImPath'. How would I allow a path dialog box to show when a developer is trying to set this property in design view?
This is easier than I thought. Just follow these 2 steps.
In your custom server control, include the System.Drawing.Design namespace by adding the following line of code at start of your code: using System.Drawing.Design;
The property for which you want to have a URL editor in design view would need to be marked with following 'UrlEditor'attribute. Look at the line below in bold:
[Category("Appearance")] [Browsable(true)] [Description("Path to image to display while page is loading")] [Editor("System.Web.UI.Design.UrlEditor", typeof(UITypeEditor))] public string LoadingImageUrl { get { return _loadingImageUrl; } set { _loadingImageUrl = value; } }
<div>Thanks</div> <div>Sunil</div>
<div>
</div>
sun21170
Marked as answer by sun21170 on Nov 07, 2011 02:21 AM
sun21170
Contributor
3421 Points
1189 Posts
Add a property called ImPath that will open a dialog box for paths in design view?
Nov 06, 2011 05:22 PM|LINK
I am developing a custom server control, that will expose a property for specifying the image path. This property is called 'ImPath'. How would I allow a path dialog box to show when a developer is trying to set this property in design view?
Thanks
Sunil
sun21170
Contributor
3421 Points
1189 Posts
Re: Add a property called ImPath that will open a dialog box for paths in design view?
Nov 07, 2011 02:21 AM|LINK
This is easier than I thought. Just follow these 2 steps.
- In your custom server control, include the System.Drawing.Design namespace by adding the following line of code at start of your code: using System.Drawing.Design;
- The property for which you want to have a URL editor in design view would need to be marked with following 'UrlEditor'attribute. Look at the line below in bold:
<div> </div>[Category("Appearance")]<div>Thanks</div> <div>Sunil</div>[Browsable(true)]
[Description("Path to image to display while page is loading")]
[Editor("System.Web.UI.Design.UrlEditor", typeof(UITypeEditor))]
public string LoadingImageUrl
{
get
{
return _loadingImageUrl;
}
set
{
_loadingImageUrl = value;
}
}