AJAX call Javascript function from Update Panel Postback

Discussion in 'ASP .Net' started by gabe, Jul 31, 2007.

  1. gabe

    gabe Guest

    How do you call a client side javascript callback method after an
    update panel has posted back to the server?

    I have two update panels (A + B) with a gridview in each panel.

    GridView B has a Trigger to listen when GridView A posts back from a
    Select button. This works fine. I can get the Postback from GridView B
    and I am able to update formatting of GridView B in it's PreRender
    Event.

    Gridview B has textboxes open in it's Item Template Mode. I can add an
    attribute that to select the data when a user clicks on a textbox.
    However, I was not able to call the Microsoft SetFocus event for a
    newly added textbox when a new row was added from the RowUpdating
    event in GridView A.

    (this works fine)
    ----------------------------------------------------------------------------------------------------------
    CType(gridRow.Cells(4).FindControl("txtRecipientAmount"),
    TextBox).Attributes.Add("onfocus", "javascript:select();")


    If I use the SetFocus method, it will work when the page posts back,
    but not the Update Panel.

    (this will work with a page post back, but not when the UpdatePanel
    posts back)
    ----------------------------------------------------------------------------------------------------------------
    CType(gridRow.Cells(4).FindControl("txtRecipientAmount"),
    TextBox).Focus()

    What I would like to do is call a javascript method on the client
    after UpdatePanel B has been fired. How do I do this?

    Thanks for the help,
    Gabe
     
    gabe, Jul 31, 2007
    #1
    1. Advertising

  2. Hello,

    There is an event in javascript that is fired when an out of bound call is
    made (you can check if the outof bound has been made by an update panel), I'm
    using in my pages something like:

    function EndRequest (sender, args) {
    if (postBackElement.id ==
    '<%Response.Write(btnSQLServerfilter.ClientID.ToString());%>')
    {

    $get('<%Response.Write(UpdateProgressSQL.ClientID.ToString());%>').style.display = "none";
    }
    }


    In my case btnSQLServerFilter is a button that fires my update panel.

    More info
    http://weblogs.asp.net/wallym/archi...quest-client-side-page-life-cycle-events.aspx

    HTH
    Braulio

    /// ------------------------------
    /// Braulio Diez
    ///
    /// http://www.tipsdotnet.com
    /// ------------------------------




    "gabe" wrote:

    > How do you call a client side javascript callback method after an
    > update panel has posted back to the server?
    >
    > I have two update panels (A + B) with a gridview in each panel.
    >
    > GridView B has a Trigger to listen when GridView A posts back from a
    > Select button. This works fine. I can get the Postback from GridView B
    > and I am able to update formatting of GridView B in it's PreRender
    > Event.
    >
    > Gridview B has textboxes open in it's Item Template Mode. I can add an
    > attribute that to select the data when a user clicks on a textbox.
    > However, I was not able to call the Microsoft SetFocus event for a
    > newly added textbox when a new row was added from the RowUpdating
    > event in GridView A.
    >
    > (this works fine)
    > ----------------------------------------------------------------------------------------------------------
    > CType(gridRow.Cells(4).FindControl("txtRecipientAmount"),
    > TextBox).Attributes.Add("onfocus", "javascript:select();")
    >
    >
    > If I use the SetFocus method, it will work when the page posts back,
    > but not the Update Panel.
    >
    > (this will work with a page post back, but not when the UpdatePanel
    > posts back)
    > ----------------------------------------------------------------------------------------------------------------
    > CType(gridRow.Cells(4).FindControl("txtRecipientAmount"),
    > TextBox).Focus()
    >
    > What I would like to do is call a javascript method on the client
    > after UpdatePanel B has been fired. How do I do this?
    >
    > Thanks for the help,
    > Gabe
    >
    >
     
    =?Utf-8?B?QnJhdWxpbyBEaWV6?=, Jul 31, 2007
    #2
    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. =?Utf-8?B?cm9kY2hhcg==?=

    datalist and ajax update panel

    =?Utf-8?B?cm9kY2hhcg==?=, Oct 2, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    733
    =?Utf-8?B?cm9kY2hhcg==?=
    Oct 2, 2006
  2. =?Utf-8?B?cm9kY2hhcg==?=

    ajax update panel trigger

    =?Utf-8?B?cm9kY2hhcg==?=, Oct 6, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    535
    =?Utf-8?B?cm9kY2hhcg==?=
    Oct 7, 2006
  3. GaryDean

    AJAX Update Panel w I.E.7 Problem

    GaryDean, Dec 4, 2006, in forum: ASP .Net
    Replies:
    10
    Views:
    5,047
    Steven Cheng[MSFT]
    Dec 12, 2006
  4. =?Utf-8?B?Qw==?=

    ASP.NET Ajax Update Panel in ContentPlaceHolder

    =?Utf-8?B?Qw==?=, Feb 12, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    1,325
    =?Utf-8?B?Qw==?=
    Feb 12, 2007
  5. DanWeaver
    Replies:
    2
    Views:
    564
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
    Feb 22, 2007
Loading...

Share This Page