UpdatePanel Postback causes Popup Window to lose Focus

Last post 08-27-2008 3:54 AM by Pawan_Mishra. 4 replies.

Sort Posts:

  • UpdatePanel Postback causes Popup Window to lose Focus

    09-17-2007, 10:29 PM

    I have an UpdatePanel that contains a timer and an infragistics webtree and when the timer fire the data is being postback (great). I also have a link that pops up a window using good old javascript window.open(...) (great).  Here's the not so great.  When the postback occurs and a node in the tree is selected with the javascript window open, it goes to the background.  I tried turning off the timer (Timer1.Enabled=false), but that didn't work.  Any suggestion is welcome

    <script runat="server">

    protected stopTimer() {

        timer1.Enabled=false;

    }

    </script>

    <script type="text/javascript">

        function stopTheTimer() {

          stopTimer();

       }

    </script>

  • Re: UpdatePanel Postback causes Popup Window to lose Focus

    09-19-2007, 5:13 AM
    Answer

    Hi,

    You cann't invoke method at server side directly in javascript.

    To stop AJAX Timer contorl,you can do it like this:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="SetTimerInterval.aspx.cs" Inherits="SetTimerInterval" %>

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

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
    <asp:scriptmanager runat="server"></asp:scriptmanager>
            <asp:Timer ID="Timer1" runat="server" Interval="3000">
            </asp:Timer>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
                </Triggers>
            </asp:UpdatePanel>
             
            <input id="Button1" type="button" value="ChangeInterval" onclick="setTimer();"/>
            <input id="Button2" type="button" value="Start" onclick="startTimer();"/>
            <input id="Button3" type="button" value="Stop" onclick="stopTimer();"/>
            <textarea id="TraceConsole"></textarea>
        <script type="text/javascript">
       
        function setTimer()
        {
            var timer = $find("Timer1");
            Sys.Debug.trace(timer.get_interval());
            timer.set_interval(100);
            Sys.Debug.trace(timer.get_interval());
        }
       
        function startTimer()
        {
            var timer = $find("Timer1");
            timer._startTimer();
        }
       
        function stopTimer()
        {
            var timer = $find("Timer1");
            timer._stopTimer();

        }
       
        </script>
        </form>
    </body>
    </html>

    Best Regards,

    Sincerely,
    Jin-Yu Yin
    Microsoft Online Community Support
  • Re: UpdatePanel Postback causes Popup Window to lose Focus

    09-19-2007, 3:41 PM

    Thanks...that makes total sense

  • Re: UpdatePanel Postback causes Popup Window to lose Focus

    08-27-2008, 3:23 AM
    • Member
      38 point Member
    • sachin_bca
    • Member since 06-26-2008, 3:43 AM
    • Delhi
    • Posts 44
    Sir can u tell me find control which you used, used for find the timer control and why we use $ before it?
  • Re: UpdatePanel Postback causes Popup Window to lose Focus

    08-27-2008, 3:54 AM
    • Star
      8,729 point Star
    • Pawan_Mishra
    • Member since 03-13-2008, 7:37 AM
    • Bangalore
    • Posts 1,272

    Hi , Check out this article which explains exactly what is $get() and $find() method of asp.net ajax :- http://mattberseth.com/blog/2007/08/the_everuseful_get_and_find_as.html .

     

    Regards
    Pawan Mishra

    Too many eyes doesn't make a good code !!!

    .Net 360°
Page 1 of 1 (5 items)