This is the parent page
CODE
protected void Page_Load(object sender, EventArgs e)
{
//Required for double click post back.
if (Page.IsPostBack)
{
if (Page.Request.Form["__EVENTTARGET"] == "lbOrgHier")
{
OrgHierCtl1.dblClick();
}
}
This is the Create Child Controls Code in the the composite control
CODE
Table tblMain = new Table();
TableRow tr = new TableRow();
TableCell tc = new TableCell();
tblMain.ID = "tblMain";
tc.ColumnSpan = 2;
Label lblHeader = new Label();
lblHeader.CssClass = "CtrlStyle";
lblHeader.ID = "lblHeader";
tc.Controls.Add(lblHeader);
tr.Cells.Add(tc);
tblMain.Rows.Add(tr);
tr = new TableRow();
tc = new TableCell();
tc.ColumnSpan = 2;
UpdatePanel up = new UpdatePanel();
up.ID = "updtPnlLb";
up.ChildrenAsTriggers = true;
AsyncPostBackTrigger _trig = new AsyncPostBackTrigger();
_trig.ControlID = "lbOrgHier";
up.Triggers.Add(_trig);
//Main List Box
ListBox lb = new ListBox();
lb.CssClass = "ListBoxStyle";
lb.ID = "lbOrgHier";
lb.SelectionMode = ListSelectionMode.Multiple;
lb.Width = 275;
//lb.Style.Add("ScrollTop",(int)ViewState["ScrollTop"]);
//This is how the page picks up the Double Click event of the control
lb.Attributes.Add("onDblClick", Page.ClientScript.GetPostBackEventReference(lb, "")); ViewState["SelectedValue"] = lb.SelectedValue;
ViewState["Click"] = 0;
up.ContentTemplateContainer.Controls.Add(lb);
tc.Controls.Add(up);
tr.Cells.Add(tc);
tblMain.Rows.Add(tr);
tr = new TableRow();
tc = new TableCell();
//Add To Filter List Button
Button btnOrgHierAddToFilterList = new Button();
btnOrgHierAddToFilterList.Click += new EventHandler(btnOrgHierAddToFilterList_Click);
btnOrgHierAddToFilterList.ID = "btnOrgHierAddToFilterList";
btnOrgHierAddToFilterList.Text = "Add To Filter";
btnOrgHierAddToFilterList.CssClass = "BtnStyle";
tc.Controls.Add(btnOrgHierAddToFilterList);
tr.Cells.Add(tc);
tc = new TableCell();
//Undo Drill Button.
Button btnUndoDrill = new Button();
btnUndoDrill.Click += new EventHandler(btnUndoDrill_Click);
btnUndoDrill.Text = "Undo Drill";
btnUndoDrill.ID = "btnOrgHierUndoDrill";
btnUndoDrill.CssClass = "BtnStyle";
btnUndoDrill.Visible = false;
tc.Controls.Add(btnUndoDrill);
tr.Cells.Add(tc);
tblMain.Rows.Add(tr);
tr = new TableRow();
tc = new TableCell();
tc.ColumnSpan = 2;
//Error Label
TextBox lbl = new TextBox();
lbl.CssClass = "CtrlStyle";
lbl.ForeColor = Color.Red;
lbl.TextMode = TextBoxMode.MultiLine;
lbl.Width = 200;
lbl.Height = 200;
lbl.ID = "lblOrgHierCtl_Error";
lbl.Visible = false;
tc.Controls.Add(lbl);
tr.Cells.Add(tc);
tblMain.Rows.Add(tr);
this.Controls.Add(tblMain);
base.CreateChildControls();
VerifyPropertyValues();
//Only want to do this once.
if (lb.Items.Count == 0)
LoadInitialValuesIntoListBox(lb);
The Main List Box is the control that has the double click.
This post has been edited by Hefe316: 7 Aug, 2008 - 11:50 AM