Last post Jun 04, 2009 09:12 AM by TampaRon
Jun 03, 2009 10:25 AM|TampaRon|LINK
I am trying to create a custom web control and need help with creating the properties of the control. Specifically I would like to include two properties.
One for an "imageURL" and the other for a "linkURL". I would like the property to work like the "imageURL" property of an image button in that when you select the property in the properties window you get the "..." eclipse button and then that pops up a dialog
box so you can select the image within the project. That should give me a relative URL.
The second property would be to allow the developer to select a linkURL to select a link to another page within the solution. This should also allow the developer to select a link using the same type of popup dialog after clicking on the "..." eclipse button.
This would allow for a relative link within the solution. Additionally I would also want to allow the developer to enter any other URL such as "abcd.com".
Any help would be greatly appreciated; point me to some coding examples, tell me how to do this or where I can find documentation for implementing these types of properties. VB or C# code is ok with me, I use both.
Jun 03, 2009 02:43 PM|Slipperman|LINK
use the following attributes for your properties (prepend to your property definition)..
----> [EditorAttribute(typeof(XmlUrlEditor), typeof(UITypeEditor))]
just change XmlUrlEditor to the right type editor for image and link (you can do a find in Object Browser)..
Jun 03, 2009 05:29 PM|TampaRon|LINK
Here is my code:
output.Write( BuildSPreContentText( uWidth.ToString(), sTitle ).ToString() + sContentText + BuildSPostContentText().ToString() );
When I compile I get these error messages:
Error 1 The type or namespace name 'XlmUrlEditor' could not be found (are you missing a using directive or an assembly reference?) E:\Documents and Settings\Ronm\My Documents\Visual Studio Projects\Controls\WindowsControlLibrary\BuildingCustomControls\BuildingCustomControls\CCContainer.cs 43 24 BuildingCustomControls
Error 2 The type or namespace name 'UITypeEditor' could not be found (are you missing a using directive or an assembly reference?) E:\Documents and Settings\Ronm\My Documents\Visual Studio Projects\Controls\WindowsControlLibrary\BuildingCustomControls\BuildingCustomControls\CCContainer.cs 43 45 BuildingCustomControls
Error 3 An attribute argument must be a constant expression, typeof expression or array creation expression E:\Documents and Settings\Ronm\My Documents\Visual Studio Projects\Controls\WindowsControlLibrary\BuildingCustomControls\BuildingCustomControls\CCContainer.cs 43 17 BuildingCustomControls
Error 4 An attribute argument must be a constant expression, typeof expression or array creation expression E:\Documents and Settings\Ronm\My Documents\Visual Studio Projects\Controls\WindowsControlLibrary\BuildingCustomControls\BuildingCustomControls\CCContainer.cs 43 38 BuildingCustomControls
What am I missing? Is there another "Using statement required"?
Jun 03, 2009 06:04 PM|Slipperman|LINK
first, it's X-m-l-UrlEditor and second, you don't want that one. you want ImageUrlEditor which if you do a search on in the ObjectBrowser, you can find the right namespace and dll reference to include. you'll have to do the same for UITypeEditor. go into
the View menu and select Object Browser to bring it up.
Jun 03, 2009 06:43 PM|TampaRon|LINK
Thank you for your quick response.
I got the Xml typo fixed.
I added "using System.Drawing.Design;" to resolve the "UITypeEditor" issue.
I replaced the XmlUrlEditor with "System.Web.UI.Design.ImageUrlEditor".
The problem now is that when I try to add "using System.Web.UI.Design" there is no such thing. The only ones available are; Adapters, HtmlControls, and WebControls. This results in the following error.
Error 1 The type or namespace name 'Design' does not exist in the namespace 'System.Web.UI' (are you missing an assembly reference?) E:\Documents and Settings\Ronm\My Documents\Visual Studio Projects\Controls\WindowsControlLibrary\BuildingCustomControls\BuildingCustomControls\CCContainer.cs 44 47 BuildingCustomControls
Jun 03, 2009 07:37 PM|Slipperman|LINK
namespaces by themselves won't be recognized unless the dll they reside in is included as a reference. in this case System.Design.
Jun 04, 2009 09:12 AM|TampaRon|LINK
Thank you very much. I had been looking for this answer for way too long and you were able to put me on the right track and answer my question in a few posts.