Home All Groups Group Topic Archive Search About

AJAX n00b - custom server control in an UpdatePanel causes full postback

Author
15 Jan 2007 10:11 PM
Monty
[apologies if this is the wrong newsgroup, couldn't find one for atlas/ajax]

Hi all,

I have a custom server control (inherits from control) that is, essentially,
a DIV containing a table with several rows, each of which has a DIV in it.
It is basically a menu of items. When the user clicks on an item div, the
event bubbles up to the table, the table calls __doPostBack and on the
server side the item is added to another DIV (let's call it
divSelectedItems). Works like a charm, but now I'd like to use an ASP.Net
AJAX UpdatePanel to do the updating of divSelectedItems when items are
selected. I put both my server control (the menu) and my divSelectedItems in
an updatepanel, but clicking on the items still causes a full postback. For
kicks, I put a button control in the update panel and add some text to the
divSelectedItems when the button is clicked. The button works with the
UpdatePanel (ie, does not cause a full postback) but my server control does
not. How can I get the UpdatePanel to convince my server control to use it's
AJAX magic rather than doing  a full postback?? TIA!

            -Monty

Author
15 Jan 2007 10:52 PM
Monty
Brief update:

I tried explicitly adding my control as a trigger (I thought this was
unecessary for controls that were IN the updatepanel, but apparently not?).
It added it like so:

Dim o As New Web.UI.AsyncPostBackTrigger()
o.ControlID = lobItems.UniqueID
o.EventName = "Click"
UpdatePanel1.Triggers.Add(o)



Now it  works for the FIRST CLICK only, after that it's back to a full
postback again. Any help? Thanks...
Author
16 Jan 2007 5:44 AM
Walter Wang [MSFT]
Hi Monty,

Without complete code of your menu-like control, it's hard to say which
part went wrong. However, we do have some guidelines on how to write an
ASP.NET AJAX-aware control:

#ASP.NET Forums - HOWTO: Write controls compatible with UpdatePanel without
linking to the ASP.NET AJAX DLL
http://forums.asp.net/thread/1445844.aspx

Please refer to above document and modify your control accordingly, and
feel free to let me know if you have any questions.

Sincerely,
Walter Wang (waw***@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Author
17 Jan 2007 7:14 PM
Monty
That is a cool article, and I implemented it in my server control, but it
did not affect the main issue I am experiencing:

The first click on my "trigger" control does an async postback perfectly -
great! The second click on it causes a full postback. Repeat ad nauseum. Any
ideas? Thanks.



Show quoteHide quote
"Walter Wang [MSFT]" <waw***@online.microsoft.com> wrote in message
news:nsJAuFTOHHA.4020@TK2MSFTNGHUB02.phx.gbl...
> Hi Monty,
>
> Without complete code of your menu-like control, it's hard to say which
> part went wrong. However, we do have some guidelines on how to write an
> ASP.NET AJAX-aware control:
>
> #ASP.NET Forums - HOWTO: Write controls compatible with UpdatePanel
> without
> linking to the ASP.NET AJAX DLL
> http://forums.asp.net/thread/1445844.aspx
>
> Please refer to above document and modify your control accordingly, and
> feel free to let me know if you have any questions.
>
> Sincerely,
> Walter Wang (waw***@online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
> ications. If you are using Outlook Express, please make sure you clear the
> check box "Tools/Options/Read: Get 300 headers at a time" to see your
> reply
> promptly.
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscriptions/support/default.aspx.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
Author
18 Jan 2007 1:02 PM
Walter Wang [MSFT]
Hi Monty,

If done correctly, the control should have no idea of AJAX but still could
update without full page postback if placed inside a UpdatePanel. Would you
please post some code or send me a reproducible web project so that I can
help find the root cause? Thanks.

Regards,
Walter Wang (waw***@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Author
29 Jan 2007 1:23 PM
baradi hakim
Hi,

I have the same problem, didi anyone resolve it ?

Thanks

Hakim

*** Sent via Developersdex http://www.developersdex.com ***
Author
29 Jan 2007 1:23 PM
baradi hakim
*** Sent via Developersdex http://www.developersdex.com ***
Author
29 Jan 2007 1:29 PM
baradi hakim
Hi,

I have the same problem, didi anyone resolve it ?

this is my code :

public class RightTable : Control, INamingContainer
{
  ...
  protected override void CreateChildControls()
        {
            this.iNbColomns = this.ColomnHeaders.Length;
            this.iNbRows = this.RowHeaders.Length;

            if (this.iNbColomns > 0 && this.iNbRows > 0)
            {
                //tblConteneur
                tblConteneur = new Table();
                //tblConteneur.BorderWidth = Unit.Pixel(1);
                TableCell td1;
                TableRow tr1 = new TableRow();
                //initialisation
                for (int i = 0; i < this.iNbColomns + 1; i++)
                {
                    td1 = new TableCell();
                    tr1.Cells.Add(td1);
                }
                tblConteneur.Rows.Add(tr1);

                TableRow tr2 = new TableRow();
                tr2.CssClass = this.HeaderStyle;

                TableCell td2 = new TableCell();
                td2.Text = (this.HeaderStyle != null && this.HeaderStyle
!= "" ? "<font class=\"" + this.HeaderStyle + "\">" : "") + this.Heading
+ (this.HeaderStyle != null && this.HeaderStyle != "" ? "</font>" : "")
;
                tr2.Cells.Add(td2);

                //first line with colomn headers
                for (int i = 0; i < this.iNbColomns; i++)
                {
                    td2 = new TableCell();
                    td2.BorderWidth = Unit.Pixel(1);
                    LinkButton lbColumnHeader = new LinkButton();
                    Header oColomnHeder = this.ColomnHeaders[i];
                    lbColumnHeader.Text = (this.HeaderStyle != null &&
this.HeaderStyle != "" ? "<font class=\"" + this.HeaderStyle + "\">" :
"") + oColomnHeder.Name + (this.HeaderStyle != null && this.HeaderStyle
!= "" ? "</font>" : "");
                    lbColumnHeader.CommandArgument =
oColomnHeder.Id.ToString();
                    lbColumnHeader.Click += new
EventHandler(LBColumnHeader_Click);
                    td2.Controls.Add(lbColumnHeader);
                    tr2.Cells.Add(td2);
                }
                tblConteneur.Rows.Add(tr2);

                bool bStyleAlernate = true;
                for (int j = 0; j < this.iNbRows; j++)
                {
                    TableRow trx = new TableRow();
                    if (bStyleAlernate)
                        trx.CssClass = this.RowStyle;
                    else
                        trx.CssClass = this.AlternatingRowStyle;

                    bStyleAlernate = !bStyleAlernate;

                    TableCell tdx = new TableCell();
                    tdx.BorderWidth = Unit.Pixel(1);
                    tdx.CssClass = this.HeaderStyle;
                    LinkButton lbRowHeader = new LinkButton();
                    RowHeader oRowHeader = this.RowHeaders[j];
                    lbRowHeader.Text = (this.HeaderStyle != null &&
this.HeaderStyle != "" ? "<font class=\"" + this.HeaderStyle + "\">" :
"") + oRowHeader.Name + (this.HeaderStyle != null && this.HeaderStyle !=
"" ? "</font>" : "");
                    lbRowHeader.CommandArgument =
oRowHeader.Id.ToString() + "," + ((int)oRowHeader.RowType).ToString();
                    lbRowHeader.Click += new
EventHandler(LBRowHeader_Click);
                    tdx.Controls.Add(lbRowHeader);
                    trx.Cells.Add(tdx);

                    for (int i = 0; i < this.iNbColomns; i++)
                    {
                        tdx = new TableCell();
                        tdx.BorderWidth = Unit.Pixel(1);
                        if (this.Values[j][i] != null)
                        {
                            TableCase TC = this.Values[j][i];
                            RightCheckBox T2dCb = new
RightCheckBox(TC.RowId, TC.ColomnId, oRowHeader.RowType);
                            T2dCb.Checked = TC.Value;
                            T2dCb.AutoPostBack = true;
                            T2dCb.CheckedChanged += new
EventHandler(CheckBoxRight_CheckedChanged);
                            tdx.Controls.Add(T2dCb);
                        }
                        trx.Cells.Add(tdx);
                    }
                    tblConteneur.Rows.Add(trx);
                }

                this.Controls.Add(tblConteneur);
            }

            this.OnControlCreated();

            this.EnabledDisabledControl(this.Controls, "", true);
        }
}

===>
In my case the CheckBox enable UpdatePanel, but not the LinkButon
Controls

*** Sent via Developersdex http://www.developersdex.com ***