Wednesday, March 21, 2012

Composite control and MaskedEdit

I have a composite control that includes a textbox. I want to use the masked edit extender on this control, but I get the 'Unable to cast object to textbox" error. Is there a work around for this?

Thanks,
Rhonda

Hi Rhoda,

The maskedEdit control is extender to object TextBox :

...
[TargetControlType(typeof(TextBox))]
public class MaskedEditExtender : ExtenderControlBase
...

The MaskedEdit Control would not have as to control composite. For example , The composite has 2 textbox. Which will be associated? On the events, that events will be controlled (ex: keypress), of the composite or internal the textbox ?


Hi Rhodas,

Perhaps workaround is to create one webcontrol with Textbox + MaskedEdit.


I like the idea of adding the masked edit to my composite control, but I'm not sure how to do that. There's no HTML involved and I can't access the extender in code. Any ideas?

Thanks,
Rhonda


Hi Rhonda,

Sorry, I worte wrong :

.. create onewebUsercontrol with Textbox + MaskedEdit.


Glad I found that thread; that's exactly what I'm trying to do (a composite control with a textbox and a FilteredTextBoxExtender)!

I haven't had any luck 'till now (those are my first custom controls, and tutorials for that subject are rare, to say the least...)

Now, am I understanding correctly that you are saying that ExtenderControls can't be encapsulated in CustomServerControl? (I'm deriving from CompositeControl, for my part.)

regards.

No comments:

Post a Comment