Timer, UpdatePanel, Focus

Rate It (2)

Last post 11-27-2007 5:49 PM by noldor. 4 replies.

Sort Posts:

  • Timer, UpdatePanel, Focus

    04-16-2007, 8:12 AM
    • Loading...
    • angel1058
    • Joined on 10-11-2006, 10:53 AM
    • England
    • Posts 8

    Hi

    Scenario:

     I have an updatepanel, with an embedded timer. This panel does little more than display how much time is left before the next 'event'.  It updates a ASP:Label every 10 seconds.  No problems there.  I suggested every minute to the client, they wanted every second, so we agreed on 10 seconds (all irrelevant).

     On another part of the same page, I have an edit box with an autocomplete extender.  This also worked a treat.

    Problem: 
    If the user is typing into the editbox when the updatepanel with the time in refreshes, the focus is lost.
    If the autocomplete list is displayed on the user to select from, and the updatepanel timer fires, the extender disappears.

    I also have a button which displays a popupcontrol (using the extender) and this went away on the timer update as well, but I cheated here by disabling the timer whilst the popupcontrol was on the screen, and re-enabling (undisable?) it when the popupcontrol went away.  but that isn't so easy with the TextBox / Focus problem.

    Solution:???
    Is there anyway I can have a control, which updates itself visually on the screen (and does some background stuff in CodeBehind), without interfering with anything else on the screen?  ie focus, floating divs/panels etc.

    Cheers

    Malcolm

  • Re: Timer, UpdatePanel, Focus

    04-16-2007, 11:06 AM
    Answer
    • Loading...
    • grantm
    • Joined on 10-28-2006, 8:37 AM
    • Posts 27

    I had a very similair problem, and i'm not sure how the solution will work in your scenario, but here goes

    I had a div that displayed data from the database (refresh every 5 seconds),
    as well a textbox with button that submitted data to the database.

    I was having the problem where you would be typing in the textbox, and as the div refreshed you would lose focus on the textbox (as well as the last few types characters).

    This was fixed by placing the div in it's own UpdatePanel, and the textbox and button in it's own update panel.
    The textbox & button Update Panel had it's UpdateMode="Conditional"

        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <div id="chatwindow">
                        <asp:Label ID="lblChatWindow" runat="server"></asp:Label>
                </div>
                <asp:Timer ID="Timer1" runat="server" OnTick="Timer1_Tick" Interval="5000"></asp:Timer>
            </ContentTemplate>
        </asp:UpdatePanel>
        <asp:UpdatePanel id="UpdatePanel2" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <div id="chatinput">
                    <asp:TextBox id="tbNewChat" runat="server" Width="150px" CssClass="textbox"></asp:TextBox>
                    <asp:Button ID="btnSubmit" runat="server" Text="Submit" CausesValidation="false" OnClick="btnSubmit_Click" CssClass="button" />
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
     
  • Re: Timer, UpdatePanel, Focus

    04-16-2007, 11:38 AM
    • Loading...
    • angel1058
    • Joined on 10-11-2006, 10:53 AM
    • England
    • Posts 8

    Thanks for this -  I will give it a whirl on the train home tonight.  I'll let you know either way....

     Cheers

     Malc

  • Re: Timer, UpdatePanel, Focus

    04-16-2007, 4:50 PM
    • Loading...
    • angel1058
    • Joined on 10-11-2006, 10:53 AM
    • England
    • Posts 8

    Excellent!!  I had nested updatepanels.  The out one had UpdateMode=Conditional and the inner one didn't.  Setting UpdateMode=Conditional on the inner panel, the one with the edit control, and popup works a treat.

    Thanks for taking the time on this one.  No doubt it won't be my last!!

    Cheers

    Malc

  • Re: Timer, UpdatePanel, Focus

    11-27-2007, 5:49 PM
    • Loading...
    • noldor
    • Joined on 04-26-2007, 3:28 PM
    • Posts 8

    I have the same issue. 

    This solution works for Internet Explorer, but not for Firefox.

    Is there any other way to fix this problem ??
     

Page 1 of 1 (5 items)