Sunday, March 11, 2012

Loosing focus after timer Tick

This is because the HTML markup of the textbox is placed within the UpdatePanel. After callback completes the HTML of the update panel is replaced with new HTML, so the original DHTML textbox deos not exists any more. What you need to do is to bring textbox outside the update panel? I could not think of any good reason why you need the textbox in the update panel.

hello.

btw, the easiest way to set the focus is to handle the propertychanged event of the pagerequestmanager. i f you search this forum, you'll find a sample written by me that illustrates how this can happen (yep, it didn't work with the focus server mehtod).


<body> <form id="form1" runat="server"> <atlas:TimerControl Interval="2000" ID="contentReload" runat="server" Visible=true OnTick="contentReload_Tick"> </atlas:TimerControl> <table style="height:100%;width:100%"> <tr> <td style="width:80%;border: solid 1pt black;height:80%;overflow:scroll">  <atlas:UpdatePanel ID="contentUPanel" runat="server"> <ContentTemplate> <asp:Label ID="contentLbl" runat="server" Text="" /> </ContentTemplate> <Triggers> <atlas:ControlEventTrigger ControlID="sendBtn" EventName="Click" /> <atlas:ControlEventTrigger ControlID="contentReload" EventName="Tick" /> </Triggers> </atlas:UpdatePanel> </td> <td style="width:20%;border: solid 1pt black;">  <atlas:UpdatePanel ID="usersPanel" runat="server"> <ContentTemplate> <asp:Label ID="usersLbl" runat="server" /> </ContentTemplate> </atlas:UpdatePanel> </td> </tr> <tr> <td colspan="2"> <asp:TextBox ID="sendtext" runat="server"></asp:TextBox> <asp:Button ID="sendBtn" runat="server" Text="Send" OnClick="sendBtn_Click" /> </td> </tr> </table> </form> <script type="text/xml-script"> <page xmlns:script="http://schemas.microsoft.com/xml-script/2005"> <references> </references> <components> </components> </page> </script></body>

<asp:TextBox ID="sendtext" runat="server"></asp:TextBox>

This texbox loose focus...


hello.

well, as i said before, you'll have to handle the end of the partial postback operation and set the focus on that control through javascript or xml-script (not really sure now if there's a method which can be called from xml-script that sets the focus on the control...). there are several entries here already which explain how to do that. just search the forums for "_inPostBack pagerequestmanager" and you should get several hits...

No comments:

Post a Comment