Providing Browse capabilities for a File in property grid

T

Trevor Andrew

Hi There,

I am developing a custom control which has a property that represents a file
within the current web application (an XML file as it turns out). I would
like the property grid builder button to invoke the same sort of editor as
used by the standard XML web form control properties DocumentSource and
TransformSource.

I suspect I have to set the Editor attribute of my control's property to a
certain value, but I don't know what. Can someone assist?

Additionally, can someone point me in the direction of documentation from
which I should have been able to deduce this myself?

Thanks in Advance,
Trevor Andrew
 
V

Victor Garcia Aprea [MVP]

Hi Trevor,

DocumentSource uses the XmlUrlEditor and TransformSource uses the
XslUrlEditor, both types are found in the System.Web.UI.Design namespace.
You need to use the EditorAttribute metadata attribute to assign an editor
to your property, ie:
[C#]
[Editor(typeof(System.Web.UI.Design.XmlUrlEditor),typeof(System.Drawing.Desi
gn.UITypeEditor))]
public String YourProperty

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx
To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
and not by private mail.
 
V

Victor Garcia Aprea [MVP]

You will need to add a reference to the "System.Design.dll" assembly to your
project (Solution Explorer->References->Add References). That should do it.

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx
To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
and not by private mail.

Trevor Andrew said:
Hi Victor,

Thank you once again ... I will certainly go and take a look at those two
books. I should have mentioned that I am building this control on VB.NET,
and have translated your answer to the following under VB:

Editor(GetType(System.Web.UI.Design.XmlUrlEditor),
GetType(System.Drawing.Design.UITypeEditor))
And I have an "Imports System.Web.UI" at the top of my VB file, but it can't
resolve the System.Web.UI.Design.XMLUrlEditor type. I can't find it in the
object browser either. There doesn't even appear to be a design namespace
under System.Web.UI from where I'm looking. Is this something I can't do
with VB.NET or have I got it misconfigured.

Once again, your help is much appreciated.

Regards,

Trevor Andrew

I've answered this question a couple of times; thanks to the great indexing
provided by http://groups.google.com you could have been able to find a
quicker (faster than mine!) answer by searching there.

If you're looking into custom control development then there are two books
that should read:

Developing Microsoft ASP.NET Server Controls and Components
by Nikhil Kothari
http://www.amazon.com/exec/obidos/ASIN/0735615829/laplatayacom"/104-7550369-4522300
Professional ASP.NET Server Controls: Building Custom Controls with C#
by Daniel Cazzulino et all
http://www.amazon.com/exec/obidos/tg/detail/-/1861005644/laplatayacom/104-7550369-4522300
I've read the first one and its very recommendable. I've not read the second
one but I've worked as a reviewer for a few of its chapters and they're top
quality. Plus, Daniel Cazzulino really knows his stuff.

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx
To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
and not by private mail.

Trevor Andrew said:
Hi Victor,

Thank you so much for your very prompt response on this question!

Should I have been able to find that out for myself? What books /
documentation do you recommend for gaining a deeper understanding of the
issues associated with web custom control development?

Once again, Thank You very much,
Trevor Andrew

Hi Trevor,

DocumentSource uses the XmlUrlEditor and TransformSource uses the
XslUrlEditor, both types are found in the System.Web.UI.Design namespace.
You need to use the EditorAttribute metadata attribute to assign an editor
to your property, ie:
[C#]
[Editor(typeof(System.Web.UI.Design.XmlUrlEditor),typeof(System.Drawing.Desi
gn.UITypeEditor))]
public String YourProperty

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx
To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
and not by private mail.

Hi There,

I am developing a custom control which has a property that
represents
a
file
within the current web application (an XML file as it turns out). I
would
like the property grid builder button to invoke the same sort of editor
as
used by the standard XML web form control properties
DocumentSource
and
TransformSource.

I suspect I have to set the Editor attribute of my control's
property
to
a
certain value, but I don't know what. Can someone assist?

Additionally, can someone point me in the direction of documentation
from
which I should have been able to deduce this myself?

Thanks in Advance,
Trevor Andrew
 
V

Victor Garcia Aprea [MVP]

You can do some optimizations with C# that you can't do with VB.NET. One of
the main issues against using VB.NET for control development was a bug in
the compiler that should be fixed by now (I haven't checked as I don't
really use vb.net much). If you could make a choice I would suggest using
C#.

Regarding obfuscation I really don't see much sense in it at all. I mean, if
someone wants to decompile your code the obfuscator won't prevent this, it
will only make his/her job a little bit tedious but not impossible at all.
So using obfuscation you could avoid newbies eyes to understand the code,
but anyone with a bit of time would be able to do it. If you *really* want
to hide some code your best bet may be to implement it in native code and
call it from your .net code, that will help the hiding a bit, but again, if
someone takes the decompiling seriously shouldn't have much of a problem
decompiling it.

Glad you finally got it working, and thanks for getting back!

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx
To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
and not by private mail.

Trevor Andrew said:
Victor,

Your help has been invaluable to me ... I've just gone out and purchased
Kothari and Datye book, and at first glance it seems very impressive. Some
of the reviews on the other book at Amazon were a little less kind.
Unfortunately, purchasing from Amazon isn't a good option for me in
Australia because even though the books are cheaper, the freight costs are
the killer, and the delays involved are frustrating.

One quick question. If I continue down the path I am, and come up with what
I consider to be a useful ASP.NET custom control, are there any significant
disadvantages to continuing developing it in VB.NET instead of C#? From my
brief reading of the Kothari book's introduction, he suggests that there
aren't any significant differences. What's your opinion?

And what about issues of code obfuscation? For a commercially released
ASP.NET custom control, would you consider obfuscation to be important?

I hope I'm not taking too much of your time. Once again, thank you for your
invaluable help.

Regards,
Trevor Andrew


Victor Garcia Aprea said:
You will need to add a reference to the "System.Design.dll" assembly to your
project (Solution Explorer->References->Add References). That should do it.

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx
To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
and not by private mail.
find
http://www.amazon.com/exec/obidos/A...-/1861005644/laplatayacom/104-7550369-4522300
I've read the first one and its very recommendable. I've not read the
second
one but I've worked as a reviewer for a few of its chapters and they're
top
quality. Plus, Daniel Cazzulino really knows his stuff.

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx
To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
and not by private mail.

Hi Victor,

Thank you so much for your very prompt response on this question!

Should I have been able to find that out for myself? What books /
documentation do you recommend for gaining a deeper understanding
of
the
issues associated with web custom control development?

Once again, Thank You very much,
Trevor Andrew

Hi Trevor,

DocumentSource uses the XmlUrlEditor and TransformSource uses the
XslUrlEditor, both types are found in the System.Web.UI.Design
namespace.
You need to use the EditorAttribute metadata attribute to assign an
editor
to your property, ie:
[C#]
[Editor(typeof(System.Web.UI.Design.XmlUrlEditor),typeof(System.Drawing.Desi
gn.UITypeEditor))]
public String YourProperty

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx
To contact me remove 'NOSPAM'. Please post all questions to the
newsgroup
and not by private mail.

Hi There,

I am developing a custom control which has a property that
represents
a
file
within the current web application (an XML file as it turns
out).
I
would
like the property grid builder button to invoke the same sort of
editor
as
used by the standard XML web form control properties DocumentSource
and
TransformSource.

I suspect I have to set the Editor attribute of my control's
property
to
a
certain value, but I don't know what. Can someone assist?

Additionally, can someone point me in the direction of documentation
from
which I should have been able to deduce this myself?

Thanks in Advance,
Trevor Andrew
 

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,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top