Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
i have two div, one textbox, one button in a page and 1 timer control, i have 2 update panels. i placed (two divs) in one update panel and i placed (timer control) in an other update panel, because i want to reset or update dives all fields when button is clicked so that dives should be updated,and where timer control tick event is fired i rebind the div or refresh the div , i have done this and it works properly but problem is that when i am going to write some text in textbox or i want to focus on textbox, so how can i maintain focus, or even how can i get focus of current control and after firing of timer control tick event i should reassing focus of such control my code is below.

/* hover state */
.chat-box > input[type="checkbox"]:hover + label {background-color:#404D5A}

/* checked state */
.chat-box > input[type="checkbox"]:checked + label {background-color:#212A35}
.chat-box > input[type="checkbox"]:checked + label:before {content:attr(data-expanded); float:right}
.chat-box > input[type="checkbox"]:checked ~ .chat-box-content {display:block}


XML
<asp:UpdatePanel ID="upbtnSend" runat="server"><ContentTemplate>
    <table>
    <tr><td>
    <div id="divMessages" class="chat-box" style="width:610px;" onresize="SetScrollPosition()"><%--padding: 4px 4px 4px 4px; border-color:Black;border-width:1px;border-style:solid;--%>
                                 <input type="checkbox" />
                                 <label data-expanded="Close Chatbox" data-collapsed="Open Chatbox"><asp:Label Id="lblRoomName" Font-Size="18px" runat="server" style="float:left" /></label>
                                <div class="chat-box-content" style="background-color: White; height:300px;width:592px; overflow-y:scroll; font-size: 11px; ">
                                <asp:Literal Id="litMessages" runat="server" />
                                <asp:Label ID="lblUserNames" runat="server" Visible="false" Font-Bold="true" ForeColor="Blue"></asp:Label>


                                <asp:TextBox Id="txtMessage" onkeyup="ReplaceChars()" onfocus="SetToEnd(this)" runat="server" MaxLength="100" Width="500px" />


     <asp:Button ID="btnSend" runat="server" Text="Send" onclick="btnSend_Click"/>

</td><td>

    <div onload="javascript:register_popup('narayan-prusty', 'Narayan Prusty');" id="divUsers" style="background-color: White; border-color:Black;border-width:1px;border-style:solid;height:337px;width:150px;overflow-y:scroll; font-size: 11px;  padding: 4px 4px 4px 4px;">
                               <asp:Literal Id="litUsers" runat="server">
                               <a href="javascript:register_popup('narayan-prusty', 'Narayan Prusty');">
                               </asp:Literal>

                            </div></td>

    </tr></table></ContentTemplate>
    </asp:UpdatePanel>
    <asp:UpdatePanel ID="upTimer" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false"><ContentTemplate>
    <asp:Timer Id="Timer1" Interval="7000" OnTick="Timer1_OnTick" runat="server"/>
    </ContentTemplate></asp:UpdatePanel>
Posted
Comments
Sergey Alexandrovich Kryukov 20-Aug-15 8:15am    
There is no such concept as focusing a div, unless it is editable. You can focus only a control.
—SA
Dawood507 20-Aug-15 8:20am    
I mean ..Div is acting as chat box so when timer tick firing then dive getting hide when click on that then its getting up...
Sergey Alexandrovich Kryukov 20-Aug-15 11:06am    
There is no focus on it.
—SA
Dawood507 20-Aug-15 8:21am    
so shouldn't hide when timer tick fire and div should fix on wall..
Andy Lanng 20-Aug-15 8:41am    
If you don't use the "Reply" button on comments and only post comments to your own question then SA will never get notified that you have responded.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900