Wednesday, March 28, 2012

Extenders in Composite/Custom Controls

I've created composite or custom controls with ajaxcontrol extenders, example is a textbox with FilteredTextBoxExtender. So far I am able to make the new control work.

My problem is how to expose the extender's properties that are of enumeration type like the FilterType where you can assign more than one value in comma delimited format (ex. "Number, Custom" or "UppercaseLetters, Custom")

I think it is not possible to directly access the childcontrol's (the extender) properties from the class, so how do I create a property that do the same as the extender's property?

I looked into the code of the AjaxControlToolkit, in C# its

[ExtenderControlProperty]

[DefaultValue(FilterTypes.Custom)]

publicFilterTypes FilterType

{

get {return GetPropertyValue<FilterTypes>("FilterType",FilterTypes.Custom); }set { SetPropertyValue<FilterTypes>("FilterType",value); }

}

I need a code for vb.net, I also tried converting the code using some online conversion tool but the result is not working. Here's the result:

<ExtenderControlProperty()> _

<DefaultValue(FilterTypes.[Custom])> _

PublicProperty FilterType()As FilterTypes

Get

Return GetPropertyValue(Of FilterTypes)("FilterType", FilterTypes.[Custom])

EndGet

Set(ByVal valueAs FilterTypes)

SetPropertyValue(Of FilterTypes)("FilterType", value)

EndSet

EndProperty

----

Any help is appreciated.

Solved.

Sometimes you just need to take a break to clear your mind. I was making my code complicated. :)

No comments:

Post a Comment