javascript to call on MasterPage onload

Discussion in 'ASP .Net' started by faraz, Nov 7, 2007.

  1. faraz

    faraz Guest

    I have a javascript function that i want to call masterpage load
    method called. I cant add onLoad event of body or table in master
    page.

    I have put the call to script function in <form>, it works on every
    pageLoad. seems my problem is solved. But when the pages uses
    UpdatePanel and it gets asynchronously postback. the function call at
    master page doesnt execute????? thought master page Load event gets
    called even when pages are in updatePanel.

    I want the particular function to be executed on every postback by
    updatePanel.?/??

    how can i do this..??

    thanks for replies in advance.. it is urgent !
     
    faraz, Nov 7, 2007
    #1
    1. Advertising

  2. faraz

    bruce barker Guest

    on an async postback, only script registered in the update panel will be
    executed. if you want to run on an async postback, then the update panel
    should register a call to the function. also only script registered with
    the ajax script manager will sent to the client and executed.

    -- bruce (sqlwork.com)

    faraz wrote:
    > I have a javascript function that i want to call masterpage load
    > method called. I cant add onLoad event of body or table in master
    > page.
    >
    > I have put the call to script function in <form>, it works on every
    > pageLoad. seems my problem is solved. But when the pages uses
    > UpdatePanel and it gets asynchronously postback. the function call at
    > master page doesnt execute????? thought master page Load event gets
    > called even when pages are in updatePanel.
    >
    > I want the particular function to be executed on every postback by
    > updatePanel.?/??
    >
    > how can i do this..??
    >
    > thanks for replies in advance.. it is urgent !
    >
     
    bruce barker, Nov 7, 2007
    #2
    1. Advertising

  3. faraz

    faraz Guest

    thanks for the reply.. i was wondering how would i attach the script
    function call (function is in master page) with UpdatePanel of Page?..
    and is there anything i can only with master page and have it on all
    pages?...
     
    faraz, Nov 7, 2007
    #3
  4. You can define the script manager in your master page, then:

    - Use the registerstartup script from script manager:

    http://gotjeep.net/Blogs/CommentView,guid,4be2f278-12e4-40d5-b154-0e8ecaf18fac.aspx

    - If you want to call script manager from child pages or user controls use
    the scriptmanagerproxy:

    http://aspalliance.com/1285_Tip_and_Tricks_ASPNET_20_AJAX_10_Extensions_and_Master_Pages

    http://aspadvice.com/blogs/name/arc...erPage-ScriptManager-from-a-Content-Page.aspx


    - If you want to launch some javascript after an update panel updates,
    AJAX ASP .net expose some events for that, check out EndRequest event.

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




    "faraz" wrote:

    > I have a javascript function that i want to call masterpage load
    > method called. I cant add onLoad event of body or table in master
    > page.
    >
    > I have put the call to script function in <form>, it works on every
    > pageLoad. seems my problem is solved. But when the pages uses
    > UpdatePanel and it gets asynchronously postback. the function call at
    > master page doesnt execute????? thought master page Load event gets
    > called even when pages are in updatePanel.
    >
    > I want the particular function to be executed on every postback by
    > updatePanel.?/??
    >
    > how can i do this..??
    >
    > thanks for replies in advance.. it is urgent !
    >
    >
     
    =?Utf-8?B?QnJhdWxpbyBEaWV6?=, Nov 7, 2007
    #4
  5. faraz

    faraz Guest

    thanks alot guys..EndRequest Event works ! .. I dont even have to
    register the script with scriptManager. I just had to call the my
    function in the UpdatePanel through EndRequest event.

    thanks for such quick response. :)
     
    faraz, Nov 7, 2007
    #5
    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?QWxleCBNYWdoZW4=?=

    MasterPage -> Page -> MasterPage Code Access

    =?Utf-8?B?QWxleCBNYWdoZW4=?=, Apr 10, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    7,946
    Steven Cheng[MSFT]
    Apr 14, 2006
  2. ThunderMusic
    Replies:
    2
    Views:
    473
    Gregory Gadow
    Sep 27, 2006
  3. Randy Smith
    Replies:
    9
    Views:
    464
    Mark Rae
    Apr 14, 2007
  4. mr t
    Replies:
    0
    Views:
    440
  5. Torben Laursen
    Replies:
    4
    Views:
    600
    clintonG
    Mar 15, 2008
Loading...

Share This Page