Click here to Skip to main content
15,900,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Does there exist a solution for this scenario?

I had not used Script Manager on Masterpage as it is not required when i started developing the project so i have individual scriptmanager and Update panel for each content page .In the masterpage now i had added a label which Shows System Current Time and My client want that it should change asynchonously and give a live clock feeling. Can i change the label text of master page from the Content page using Timer event which will not postback the entire page.

Thanks in advance
Posted

If you want to show the current time in your master page means you can have a javascript function()to show the time....
 
Share this answer
 
v2
Comments
Dharmenrda Kumar Singh 3-Aug-12 8:35am    
I tried from javascript but without update panel how i change the text of the label timely in masterpage?
BobJanova 3-Aug-12 9:54am    
There's an important point here. The current time can be found on the client, with pure JS; you don't need AJAX or any server side gubbins at all.
Javascript to display continuous time on the Web page. By continuous it means that it will be displayed second by second.

XML
<script type="text/javascript">
        function ShowTime()
        {
            var dt = new Date();
            document.getElementById("<%= TextBox1.ClientID %>").value = dt.toLocaleTimeString();
            window.setTimeout("ShowTime()", 1000);
        }


    </script>

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



If you are using normal Webform then it can be called on Body load event. If you are using MasterPage then it can be called within ContentTemplate at the end afte all the controls will be rendered.
 
Share this answer
 
v2
Hi,
It's not possible to update a control of master page without posting back your page.
Put your label in your MasterPage in a separate UpdatePanel.
From your Handler call a function on MasterPage(i.e. ChangeText) that changes the Text of the Label and calls Update on the MasterPage's UpdatePanel.


Try discusstion1[^] and discusstion2[^].


--Amit
 
Share this answer
 

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