Wednesday, March 21, 2012

a bug of ServicePath

the ServicePath can't parse "~/", since the control runs at "server", it should can.Agreed - we'll get a fix for this and post the code here.

Good find, mg1616! This issue was also brought up by someone else in a separate instance. I've just checked the following change in to the implementation of CascadingDropDown so it'll be available with future releases of the Atlas Control Toolkit. For now, simply paste the new method below into the implementation of the CascadingDropDown class in CascadingDropDownExtender.cs (perhaps below the OnLoad override). My testing suggests that it enables "~"-based virtual paths as requested.

Thanks so much for your help!

/// <summary>/// Override ExtenderControlBase.SerializePropertyToString to fix up virtual path references/// </summary>protected override string SerializePropertyToString(CascadingDropDownProperties props, PropertyDescriptor prop,bool force){string result =base.SerializePropertyToString(props, prop, force);// Fix up virtual path references for the ServicePath propertyif ("ServicePath" == prop.Name) { result = ResolveClientUrl(result); }return result;}

Regarding this:

if ("ServicePath" == prop.Name)

It seems to me that we have some incestuous knowlege of the name of the property. I suggest that in general the property names should be exposed by the respective Properties class. This would eliminate a whole host of oopsies. That gets us to:

public class CascadingDropDownProperties : TargetControlPropertiesBase<DropDownList>{// Constant strings for each property namepublic const string stringParentControlID ="ParentControlID";public const string stringCategory ="Category";public const string stringPromptText ="PromptText";public const string stringServicePath ="ServicePath";public const string stringServiceMethod ="ServiceMethod";

Of course, that makes the names of the constants appear quite ugly (I thought "Hungarian" notation was dead by now). My coding convention leads to this:

public class CascadingDropDownProperties : TargetControlPropertiesBase<DropDownList>{// Constant strings for each property namepublic static class PropertyName {public static readonly string ParentControlID ="ParentControlID";public static readonly string Category ="Category";public static readonly string PromptText ="PromptText";public static readonly string ServicePath ="ServicePath";public static readonly string ServiceMethod ="ServiceMethod"; };


Yeah, I see your point. I'm not really sure that makes ita lotbetter with respect to your concern. In either case you're still relying on the property string name. Your method is a little better, I'll agree.

But in this case, David and I were talking and think we have an even more general solution in mind that would require none of this. Basically, mapping a property to a client URL is something that will happen regularly so I think we'll bake this into the framework for our next release, probably later this month.

Thanks!

No comments:

Post a Comment