Saturday, March 24, 2012

Derived Textbox Not Recognized as Textbox

Hi All,

I have a derived text box class that inherits directly off of TextBox. I have this textbox on a page, and when I use the TextboxWatermark extender and set the TargetControlID to my textbox's ID Atlas doesn't seem to realize that it's a textbox, but just a control. We surmised this because the extender throws an error on "this.control.get_text();" while it's happy to execute "this.control_getCssClass();"

If I use a regular ASP textbox on the page, the extender is a happy camper. Anybody have any thoughts about this?

Thx.

I am having the same issue with the toolkit samples as well. Did you find a fix or reason for this? I also do not have any the properties available in the property box in VS2005 for any of the Atlas controls. But I can go to the source and enter the properties fine.

Dale


We haven't gotten an answer yet. I'm going to try another avenue and see if I get anywhere. I'll post any results.

Oh man, I can't believe I screwed that up. We added code that checks the type of the control being extended and then tweaks the generated XML type based on that so the client side can talk to the specific type (e.g. Sys.UI.TextBox instead of Sys.UI.Control). Well it looks in a hashtable based on the type of the control. So if they type isn't exact, the lookup fails. Darn.

Anyway, here's how to work around it. You just need to do a simple override of the TextboxWatermarkExtender. If VS starts complaining about the reference to ExtenderControlBase, click on "Microsoft.AtlasControlExtender" in your reference and change "Specific Version" to true. I'm not sure why mine got angry about that, but just in case you see it.

public class MyTextBox : System.Web.UI.WebControls.TextBox { }public class MyTextboxWaterMarkExtender : AtlasControlToolkit.TextBoxWatermarkExtender {protected override string GetClientClassForControl(System.Web.UI.Control control) {if (controlis System.Web.UI.WebControls.TextBox) {return"textBox"; }return base.GetClientClassForControl(control); } }

Hey Shawn,

Thanks for the work around. We'll get to testing it this afternoon.

It's a sweet toolkit and the bugs (aka job securitySmile [:)]) will get worked out.

No comments:

Post a Comment