Wednesday, March 21, 2012

composite Web user controls and the Control Tookit object / element finder

I have written a control using the toolit. However, I am having a slight problem. I am having errors finding other elements on a page, where the page is made up of controls that have controls.

For example, a page has the following controls on it "OrderActionMenu1", which has a control "OrderHoldPanel" on it.

Controls on the "OrderHoldPanel include the below.

I can get the atlas to find the control I want to bind, if I Fully namespace the controls i want to find.

How can I use the findeer better? The idea of putting the Atlas code in the control is for re-use, and namespacing is breaking the re-use. For some reason, the built in "TargetControlID" works fine. How can I make my TargetPanelID and CloseLinkID work similarly, without the namespace?

I have highlighted the issue in yellow.

Here is how the code builds the behavior.

_targetPanelElement = $(_targetPanelID);

debug.

assert(_targetPanelElement,"Couldn't find HTML element '" + _targetPanelID +"'");// Create a control wrapper and behavior for the popup controlif (_targetPanelElement) {

_popupBehavior =

new Sys.UI.PopupBehavior();

_popupBehavior.set_parentElement(

this.control.element);

_popupBehavior.set_id(

"popupBehavior");

_popupBehavior.set_positioningMode(_positioningMode);

_popupBehavior.set_x(_offsetX);

_popupBehavior.set_y(_offsetY);

_targetPanelControl = $object(_targetPanelID);

if (!_targetPanelControl) {

_targetPanelControl =

new Sys.UI.Control(_targetPanelElement);

_targetPanelControl.initialize();

}

_targetPanelControl.get_behaviors().add(_popupBehavior);

_popupBehavior.initialize();

Thanks,

Geoff

<cc1:HyperlinkPopupControlPropertiesAllowHover="false"CloseLinkID="OrderActionMenu1_OrderHoldPanel1_lnkHoldPopUpClose"

TargetControlID="lnkChangeHold"TargetPanelID="OrderActionMenu1_OrderHoldPanel1_pnlHold"/>

OrderHoldPanel control

<

asp:HyperLinkID="lnkChangeHold"runat="server"CssClass="psuedoLink">Change Hold</asp:HyperLink>

<

asp:PanelID="pnlHold"runat="server"CssClass="ModalPopUP500"><aid="lnkHoldPopUpClose"runat="server"style="float: right;"><imgsrc="http://www.wine.com/images/glo_icon_remove.gif"alt="close"/></a><divclass="divPadding"><atlas:UpdatePanelrunat="server"ID="pnlUpdHold"Mode="Conditional"><ContentTemplate><asp:LabelID="lblCurrentHold"runat="server">The Current Hold If Any</asp:Label><asp:DropDownListID="ddlHoldReasons"runat="server"OnSelectedIndexChanged="ddlHoldReasons_SelectedIndexChanged"AutoPostBack="true"><asp:ListItemValue="Dry Cnty">Dry Address</asp:ListItem><asp:ListItemValue="Fraud">Fraud Check</asp:ListItem><asp:ListItemValue="OOS">Out of Stock</asp:ListItem><asp:ListItemValue="VIN-SUB">Vintage Sub</asp:ListItem><asp:ListItemValue="Duplicate">Duplicate Order</asp:ListItem><asp:ListItemValue="CSR Hold">CSR Hold</asp:ListItem></asp:DropDownList><br/><asp:LabelID="lblHoldReason"runat="server">The Hold reasons Description will go here</asp:Label><br/><asp:ButtonID="btnApplyHold"runat="server"Text="Apply"OnClick="btnApplyHold_Click"/><asp:ButtonID="btnClearHold"runat="server"Text="Clear"OnClick="btnClearHold_Click"/></ContentTemplate></atlas:UpdatePanel><cc1:HyperlinkPopupControlExtenderID="holdPopupExtender"runat="server"><cc1:HyperlinkPopupControlPropertiesAllowHover="false"CloseLinkID="OrderActionMenu1_OrderHoldPanel1_lnkHoldPopUpClose"TargetControlID="lnkChangeHold"TargetPanelID="OrderActionMenu1_OrderHoldPanel1_pnlHold"/></cc1:HyperlinkPopupControlExtender></div>

</

asp:Panel>

In your HyperlinkPopupControlProperties class, add the [IDReferenceAttribute()] to your CloseLinkID and TargetPanelID. This will cause the framework to automatically do the mapping you're looking for.

public class HyperlinkPopupControlProperties {[IDReference(typeof(HyperLink)]public string CloseLinkID{}[IDReference(typeof(Panel))]public string TargetPanelID {}}

That Solved It! Thanks a ton!

No comments:

Post a Comment