richard
-
7/12/2010 5:03:12 AM
RE:Reference a control in the transformation from a user control
Thanks Pavel
Yeah there was a specific reason why it could not be in the control itself - mainly a layout issue.
Here is the code I am using the find the controls in the parent page - it is a bit of a dog as you need to define the return variable outside the scope of the function .... Cheers
getAllCtl(Page.Controls, "ProductQuantity", "System.Web.UI.WebControls.DropDownList");
public void getAllCtl(ControlCollection ctls, string ctrlID, string ctrlType) {
//Response.Write("<br>ctrlcount"+ctls.Count.ToString());
//Response.Clear(); // foreach (Control c in ctls) { //controls.Text = controls.Text + "CONTROLS"+c.ToString()+":"+ctls.Count.ToString()+"<br>"; // Response.Write("<br>TYPE"+c.GetType().ToString()); try { // Response.Write("<br>NAME" + c.ID.ToString() + "<BR>"); } catch { }
if (c.GetType().ToString() == ctrlType) { if (ctrlType == "System.Web.UI.WebControls.DropDownList") { DropDownList tt = c as DropDownList;
if (tt.ID.ToString() == ctrlID) {
myc = tt;
}
} else if (ctrlType == "CMS.PortalControls.CMSUpdatePanel") {
CMS.PortalControls.CMSUpdatePanel tt = c as CMS.PortalControls.CMSUpdatePanel;
if (tt.ID.ToString() == ctrlID) {
// Response.Write("<BR>MYDROPDOWN:" + tt.ID.ToString());
myc = tt;
}
}
} else { if (myc != null) { } else { if (c.HasControls()) { getAllCtl(c.Controls, ctrlID, ctrlType); } } } }
}
|