locked
UserControl Time auto change in dnn RRS feed

  • Question

  • User1139542394 posted

    Hi

    My site is a dnn site.In this I have to change my time dynamically (ex : 19:15:08 )


    So here how can i do it javascript for usercontrol or anyother alternative can i use.


    Bec i have used sql with time control but it takes little bit time for doing other functionlity.so next time seconds are chaning 19:15:12 somehting.


    but user should see 19:15:08 and after that 19:15:09


    if i used the javascript


    <html>
    <head>
    <title>(Type a title for your page here)</title>

    <script type="text/javascript">
    function display_c(){
    var refresh=1000; // Refresh rate in milli seconds
    mytime=setTimeout('display_ct()',refresh)
    }

    function display_ct() {
    var strcount
    var x = new Date()
    document.getElementById('ct').innerHTML = x;
    tt=display_c();
    }
    </script>
    </head>

    <body onload=display_ct();>
    <span id='ct' ></span>

    </body>

    </html>


    it working fine for page.but i want it for Usercontrol for dnn site


    Please guide me for this




    Monday, December 6, 2010 9:33 AM

Answers

  • User1139542394 posted

    got the solution.


    Below is the Code.


    <script type="text/javascript">

    if (window.attachEvent) {

    window.attachEvent("onload", display_c);
    }

    function display_c()
    {


    var refresh=1000; // Refresh rate in milli seconds
    mytime=setTimeout('display_ct()',refresh)
    }

    function display_ct() {

    var strcount
    var x = new Date()
    document.getElementById('ct').innerHTML = x;
    tt=display_c();
    }
    window.onload = display_c;
    </script>


    <div>
    <span id='ct' ></span>
    <asp:Label ID="lblTime" runat="server">
    </asp:Label>
    </div>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 6, 2010 10:30 AM

All replies

  • User-1598917946 posted

    user control and all the scripts are bound to parent page so you don't have to worry if it will be executed or not

    Monday, December 6, 2010 9:58 AM
  • User1139542394 posted

    yes but my parent page is dotnetnuke page.


    So i didnt get the onload event in that.


    please guide me for this.


    Monday, December 6, 2010 10:00 AM
  • User-1598917946 posted

    Well the only way i see is you can even make it a bit dynamic by adding the onmouseover to controls on your page and calling the same function 
    Its not perfect but it will work 

    Monday, December 6, 2010 10:07 AM
  • User1139542394 posted

    thanks for ypur reply.

    But i need it in dynamic way in each seconds. client will not accept the mouse hover.



    Monday, December 6, 2010 10:09 AM
  • User1139542394 posted

    got the solution.


    Below is the Code.


    <script type="text/javascript">

    if (window.attachEvent) {

    window.attachEvent("onload", display_c);
    }

    function display_c()
    {


    var refresh=1000; // Refresh rate in milli seconds
    mytime=setTimeout('display_ct()',refresh)
    }

    function display_ct() {

    var strcount
    var x = new Date()
    document.getElementById('ct').innerHTML = x;
    tt=display_c();
    }
    window.onload = display_c;
    </script>


    <div>
    <span id='ct' ></span>
    <asp:Label ID="lblTime" runat="server">
    </asp:Label>
    </div>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 6, 2010 10:30 AM