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

Discussion in 'ASP .Net Web Controls' started by Monty, Jan 15, 2007.

  1. Monty

    Monty Guest

    [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
    Monty, Jan 15, 2007
    #1
    1. Advertising

  2. Monty

    Monty Guest

    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...
    Monty, Jan 15, 2007
    #2
    1. Advertising

  3. 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 (, 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.
    Walter Wang [MSFT], Jan 16, 2007
    #3
  4. Monty

    Monty Guest

    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.



    "Walter Wang [MSFT]" <> wrote in message
    news:...
    > 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 (, 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.
    >
    Monty, Jan 17, 2007
    #4
  5. 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 (, 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.
    Walter Wang [MSFT], Jan 18, 2007
    #5
  6. Monty

    baradi hakim Guest

    baradi hakim, Jan 29, 2007
    #6
  7. Monty

    baradi hakim Guest

    baradi hakim, Jan 29, 2007
    #7
  8. Monty

    baradi hakim Guest

    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;
    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] != null)
    {
    TableCase TC = this.Values[j];
    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 ***
    baradi hakim, Jan 29, 2007
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Xavier Osa
    Replies:
    0
    Views:
    618
    Xavier Osa
    Jan 9, 2004
  2. seeker
    Replies:
    0
    Views:
    369
    seeker
    Feb 20, 2007
  3. =?Utf-8?B?TGlhbQ==?=

    AJAX update panel causes full page post back

    =?Utf-8?B?TGlhbQ==?=, Oct 15, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    734
    =?Utf-8?B?TGlhbQ==?=
    Oct 15, 2007
  4. TomK
    Replies:
    1
    Views:
    1,927
    Manish
    Feb 6, 2008
  5. TomK
    Replies:
    2
    Views:
    239
Loading...

Share This Page