sohrabus
asked on
Timer
Hi,
How can I add following Code in Usercontrol of ASP.NET.
i HAVE A USERCONTROL in that i have Time Label and I want to show time:
Since there is no head, body tag in user control, how can i add following code in ASP.NET USERCONTROL:
<HEAD>
<script language="JavaScript" type="text/javascript">
function sivamtime() {
now=new Date();
hour=now.getHours();
min=now.getMinutes();
sec=now.getSeconds();
if (min<=9) {min="0"+min; }
if (sec<=9) {sec="0"+sec; }if (hour<10) {hour="0"+hour; }
document.Form1.LBLTIME.val ue = hour + ":" + min + ":" + sec;
setTimeout("sivamtime()", 1000);
}
</script>
</HEAD>
<BODY onload="sivamtime()">
How can I add following Code in Usercontrol of ASP.NET.
i HAVE A USERCONTROL in that i have Time Label and I want to show time:
Since there is no head, body tag in user control, how can i add following code in ASP.NET USERCONTROL:
<HEAD>
<script language="JavaScript" type="text/javascript">
function sivamtime() {
now=new Date();
hour=now.getHours();
min=now.getMinutes();
sec=now.getSeconds();
if (min<=9) {min="0"+min; }
if (sec<=9) {sec="0"+sec; }if (hour<10) {hour="0"+hour; }
document.Form1.LBLTIME.val
setTimeout("sivamtime()", 1000);
}
</script>
</HEAD>
<BODY onload="sivamtime()">
ASKER
Dear Niraj,
Presently I'm doing the same u have explained. I made User control n put label for time and then attach this user control to my all .aspx pages. Till here OK.
But now My requirement is that I want a tick time which is not possible in asp.net and it is possible from JavaScript.
The above code which i wrote 1st time is giving tick time BUT how can i add THAT code in ASP.NET USERCONTROL since <Head> and <Body> Tag is used in this code.
Can I use <Head> and <Body> <Form> tag in USERCONTROL.
Presently I'm doing the same u have explained. I made User control n put label for time and then attach this user control to my all .aspx pages. Till here OK.
But now My requirement is that I want a tick time which is not possible in asp.net and it is possible from JavaScript.
The above code which i wrote 1st time is giving tick time BUT how can i add THAT code in ASP.NET USERCONTROL since <Head> and <Body> Tag is used in this code.
Can I use <Head> and <Body> <Form> tag in USERCONTROL.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<INPUT type="button" id="btnTime" style="BACKGROUND-COLOR: transparent">
you can modify the button if u want the background to b transparent....
hi sohrabus,
i was waiting to hear from you. Did the above solution solved your problem or not. If you could tell me.
Just go to code behind of the user control ( .ascx.cs for C#) and add the following code on the page load event.
Label1.Text=DateTime.Now.T
You have to place this user control on .aspx page. Label1 will display the time of the machine when the .aspx page is loaded.
i hope it would help you...please let me know if u have any problem doing so.