Web Custom Control using a property displaying current form text boxes

J

Jay Douglas

I'm trying to add a property to a Web Custom Control that behaves just like
the ControlToValidate string property on the built in .net valuators. I
basically want the list to show the various different textboxes on the
current web form.

I've searched, and searched, and can not find an answer.

A link, or any help is appreciated.

Thanks in advance.
 
T

Tom

Just a thought :

Implement a custom editor (look in MSDN for UITypeEditor)
and attach it to to the Property with the EditorAttribute.

Override EditValue in your Editor :
public virtual object EditValue(ITypeDescriptorContext context,
IServiceProvider provider, object value);

The Instance Property of the context should point to your control :
MyControl ctrl = (MyControl) context.Instance;

With a reference to the control you should be able to iterate through the
controls in your page :
foreach (Control pageControl in ctrl.Page.Controls)
.....


HTH
Tom
 
T

Tom

I guess it's even simpler :

I had a fast look with Reflector (http://www.aisto.com/roeder/dotnet/) at
the Validation controls.
Microsoft didn't use an UITypeEditor for displaying the controls on the
page, they use a custom TypeConverter.
I recommend to get Reflector and have a look at the class
"ValidatedControlConverter".
I think, you can copy / paste most of the code from this class into your own
TypeConverter and you're done....

Regards,
Tom
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top