Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 132,173 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,530 people online right now. Registration is fast and FREE... Join Now!




Custom Composite Control Causes Full PostBack

 
Reply to this topicStart new topic

Custom Composite Control Causes Full PostBack

Hefe316
post 7 Aug, 2008 - 05:30 AM
Post #1


New D.I.C Head

*
Joined: 7 Aug, 2008
Posts: 2

I have a Custom Composite Web Control that includes a ListBox. This Control is inside an UpdatePanel on the parent page. I have code in the parent page's OnPageLoad method that handles the DblClick event. We use this same code in other apps for a regular ListBox inside of an update panel and only the UpdatePanel flickers. When I use this code with the Custom Control the entire page flickers. Is there any way to avoid this???
Also the Buttons in the composite control do only cause partial postbacks.

Any help would be greatly appreciated.

User is offlineProfile CardPM

Go to the top of the page

Jayman
post 7 Aug, 2008 - 08:28 AM
Post #2


Student of Life

Group Icon
Joined: 26 Dec, 2005
Posts: 6,839



Thanked 38 times

Dream Kudos: 500

Expert In: C#, VB.NET, Java

My Contributions


Post the code you are using and we will be happy to help you sort out the issue.
User is offlineProfile CardPM

Go to the top of the page

Hefe316
post 7 Aug, 2008 - 11:46 AM
Post #3


New D.I.C Head

*
Joined: 7 Aug, 2008
Posts: 2

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
User is offlineProfile CardPM

Go to the top of the page

kdekok
post 2 Oct, 2008 - 06:37 AM
Post #4


New D.I.C Head

*
Joined: 2 Oct, 2008
Posts: 1

Was this issue ever solved?
I have the exact same problem here, and it's driving me crazy!!

I have a custom control which contains linkbuttons, when i place my custom control inside an updatepanel and click on one of the linkbuttons, it is still performing a full postback, instead of using the partial postback of the updatepanel...

When i place a linkbutton directly inside the updatepanel, evrythings works ofcourse as it should.

Where do i look? Do i need to make my custom-control Ajax aware or something?

User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/21/08 03:22PM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month