on reload

Last post 04-21-2006 3:18 PM by Luis Abreu. 8 replies.

Sort Posts:

  • on reload

    04-20-2006, 12:24 PM
    • Loading...
    • integral
    • Joined on 10-01-2003, 6:17 PM
    • Posts 16
    hey every one i am using atlas in my webpage..but i had a question ..is there a way to call a javascript function that you wrote on page refresh sort of say..for example i have a dropdown that you can choose which category you would like to see ...when you choose your category ..using atlas i refresh only the portion of the page..so the whole page doesnot get refreshed...but i would like a javascript function that i wrote to get call as soon as atlas finishes rereshing the page ...can you guys guide me on how to do this ?
  • Re: on reload

    04-20-2006, 5:53 PM
    • Loading...
    • Luis Abreu
    • Joined on 02-12-2005, 1:22 AM
    • Madeira [Portugal]
    • Posts 5,218
    • TrustedFriends-MVPs

    hello.

    currently, the only indicator of a refresh is the inpostback property of the pagerequestmanager. though i haven't tried, it'd handle the propertyChange event fired by the pagerequestmanager...

    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    PT blog: http://weblogs.pontonetpt.com/luisabreu
    EN blog:http://msmvps.com/blogs/luisabreu
    http://www.pontonetpt.com
    http://weblogs.pontonetpt.com/
  • Re: on reload

    04-20-2006, 6:02 PM
    • Loading...
    • Luis Abreu
    • Joined on 02-12-2005, 1:22 AM
    • Madeira [Portugal]
    • Posts 5,218
    • TrustedFriends-MVPs

    oh, and here's a quick sample that is working here:

    <%

    @ Page Language="C#" %>

    <!

    DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <

    script runat="server">

    void h(

    object s, EventArgs a)

    {

    txt.Text = DateTime.Now.ToString();

    }

    </

    script>

    <

    html xmlns="http://www.w3.org/1999/xhtml" >

    <

    head runat="server">

    <title>Untitled Page</title>

    </

    head>

    <

    body>

    <form id="form1" runat="server">

    <atlas:ScriptManager runat="server" id="manager" EnablePartialRendering="true">

    </atlas:ScriptManager>

    <atlas:UpdatePanel runat="server" ID="panel">

    <ContentTemplate>

    <asp:Literal runat="server" ID="txt" />

    <asp:Button runat="server" ID="bt" OnClick="h" Text="try" />

    </ContentTemplate>

    </atlas:UpdatePanel>

    </form>

    <script type="text/javascript">

    Sys.Application.load.add( onLoad );

    function onLoad()

    {

    var page = $object("_PageRequestManager");

    page.propertyChanged.add( changed );

    }

    function changed( obj, args )

    {

    if( args.get_propertyName() && obj.get_inPostBack() == false)

    {

    alert(

    "refreshed" );

    }

    }

    </script>

    </

    body>

    </

    html>

     

    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    PT blog: http://weblogs.pontonetpt.com/luisabreu
    EN blog:http://msmvps.com/blogs/luisabreu
    http://www.pontonetpt.com
    http://weblogs.pontonetpt.com/
  • Re: on reload

    04-20-2006, 9:48 PM
    • Loading...
    • integral
    • Joined on 10-01-2003, 6:17 PM
    • Posts 16
    thank you guys..the last one worked :)
  • Re: on reload

    04-20-2006, 11:16 PM
    • Loading...
    • djeeg
    • Joined on 04-09-2006, 2:26 AM
    • Brisbane, Australia
    • Posts 15

    This is awesome, ever since moving from MagicAjax i have been missing this client triggered javascript feature on refresh. I used to have to rely on a timer that would poll a hidden field every second looking to see if the server had set it to a specific value. I shudder at the thought. Now i can just automatically trigger the code on the client. Cheers Luis.

    I have had a look for some docs on _PageRequestManager but can't find any, is this another one of those "special" objects, like the cancel commands?

  • Re: on reload

    04-21-2006, 4:09 AM
    • Loading...
    • Luis Abreu
    • Joined on 02-12-2005, 1:22 AM
    • Madeira [Portugal]
    • Posts 5,218
    • TrustedFriends-MVPs
    djeeg:

    This is awesome, ever since moving from MagicAjax i have been missing this client triggered javascript feature on refresh. I used to have to rely on a timer that would poll a hidden field every second looking to see if the server had set it to a specific value. I shudder at the thought. Now i can just automatically trigger the code on the client. Cheers Luis.

    well, in fact all credits should be given to Garbin since this was inspired by his previous post that you can check here (maybe it'll help you in other scenarios):

    http://forums.asp.net/thread/1263725.aspx

    btw, go read his blog. there you can find some great posts about atlas.

    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    PT blog: http://weblogs.pontonetpt.com/luisabreu
    EN blog:http://msmvps.com/blogs/luisabreu
    http://www.pontonetpt.com
    http://weblogs.pontonetpt.com/
  • Re: on reload

    04-21-2006, 4:33 AM
    • Loading...
    • Luis Abreu
    • Joined on 02-12-2005, 1:22 AM
    • Madeira [Portugal]
    • Posts 5,218
    • TrustedFriends-MVPs

    hello again.

    btw, just one little correction: in the if section, it shoudl be

    args.get_propertyName() == "inPostback" && ....

    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    PT blog: http://weblogs.pontonetpt.com/luisabreu
    EN blog:http://msmvps.com/blogs/luisabreu
    http://www.pontonetpt.com
    http://weblogs.pontonetpt.com/
  • Re: on reload

    04-21-2006, 1:43 PM
    • Loading...
    • integral
    • Joined on 10-01-2003, 6:17 PM
    • Posts 16

    hi one note if i add this

    args.get_propertyName() == "inPostback" && ....

     

    like you mentioned on the topic above it wont work any more

  • Re: on reload

    04-21-2006, 3:18 PM
    • Loading...
    • Luis Abreu
    • Joined on 02-12-2005, 1:22 AM
    • Madeira [Portugal]
    • Posts 5,218
    • TrustedFriends-MVPs

    hello again.

    err...  try "inPostBack"...

    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    PT blog: http://weblogs.pontonetpt.com/luisabreu
    EN blog:http://msmvps.com/blogs/luisabreu
    http://www.pontonetpt.com
    http://weblogs.pontonetpt.com/
Page 1 of 1 (9 items)
Microsoft Communities
Page view counter