Through reflection i see OnPreRender searches for a TargetProperty's TargetControl via its TargetControlID.
It only searches in NamingContainer of the Control this Extender is contained in.
I need ExtenderProperty to take both a NamingContainer and a TargetControlID so I can extend objects directly
on the page when this Extender may appear in a subcontrol.
Are ther plans to support extending Controls outside of the parent's NamingContainer space?
protectedoverridevoidOnPreRender(EventArgs e){base.OnPreRender(e);if ((this.._page;" href="http://links.10026.com/?link=http://www.aisto.com/roeder/dotnet/Default.aspx?Object=4">_page ==null) && (this.Page !=null)) {this.._page;" href="http://links.10026.com/?link=http://www.aisto.com/roeder/dotnet/Default.aspx?Object=6">_page =newPageWrapper(this.Page); }ScriptManagermanager1 =ScriptManager.GetCurrent(this.._page;" href="http://links.10026.com/?link=http://www.aisto.com/roeder/dotnet/Default.aspx?Object=12">_page);if (manager1 ==null) {thrownewInvalidOperationException("You must have a ScriptManager to use an ExtenderControl."); }Controlcontrol1 =this.NamingContainer;using (" href="http://links.10026.com/?link=http://www.aisto.com/roeder/dotnet/Default.aspx?Object=16">IEnumerator<T>enumerator1=this. Microsoft.Web.UI.ExtenderControl.TargetProperties { ... }" href="http://links.10026.com/?link=http://www.aisto.com/roeder/dotnet/Default.aspx?Object=17">TargetProperties. System.Collections.ObjectModel.Collection.GetEnumerator();" href="http://links.10026.com/?link=http://www.aisto.com/roeder/dotnet/Default.aspx?Object=18">GetEnumerator()) {while ( enumerator1 // Local Variable">enumerator1.MoveNext()) {Tlocal1 = enumerator1 // Local Variable">enumerator1..get_Current();" href="http://links.10026.com/?link=http://www.aisto.com/roeder/dotnet/Default.aspx?Object=20">get_Current();Controlcontrol2 =control1.FindControl(local1.TargetControlID);if (control2 !=null) {IScriptControlcontrol3 =manager1.RegisterControl(control2);control3.RegisterBehavior(this);continue; }thrownewInvalidOperationException(string.Format(CultureInfo.InvariantCulture,"Target control with ID '{0}' could not be found for extender '{1}'.",newobject[] {local1.TargetControlID,this.ID })); } }}The Toolkit doesn't actually run this code - we have an override that will also search for controls at the page level.
Even if the extenders took a NamingContainer property, it doesn't fix the problem. NamingContainers can be nested, so you could end up in the same situation where you can't find the naming container.
In the May 4th release of the Toolkit, we added a "ResolveTargetControlID" event that you can handle to do these types of resolutions yourself. The if the extender can't locate the Control referenced by TargetID, this event will fire and you can return the control instance.
No comments:
Post a Comment