mathieu_cupryk
asked on
i need to implement javascript function in my ascx page.
<script type="text/javascript">
<!--
function updateClock ( )
{
var currentTime = new Date ( );
var currentHours = currentTime.getHours ( );
var currentMinutes = currentTime.getMinutes ( );
var currentSeconds = currentTime.getSeconds ( );
// Pad the minutes and seconds with leading zeros, if required
currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;
// Choose either "AM" or "PM" as appropriate
var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";
// Convert the hours component to 12-hour format if needed
currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;
// Convert an hours component of "0" to "12"
currentHours = ( currentHours == 0 ) ? 12 : currentHours;
// Compose the string for display
var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay;
// Update the time display
document.getElementById("c lock").fir stChild.no deValue = currentTimeString;
}
// -->
</script>
http://www.elated.com/articles/creating-a-javascript-clock/
<!--
function updateClock ( )
{
var currentTime = new Date ( );
var currentHours = currentTime.getHours ( );
var currentMinutes = currentTime.getMinutes ( );
var currentSeconds = currentTime.getSeconds ( );
// Pad the minutes and seconds with leading zeros, if required
currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;
// Choose either "AM" or "PM" as appropriate
var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";
// Convert the hours component to 12-hour format if needed
currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;
// Convert an hours component of "0" to "12"
currentHours = ( currentHours == 0 ) ? 12 : currentHours;
// Compose the string for display
var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay;
// Update the time display
document.getElementById("c
}
// -->
</script>
http://www.elated.com/articles/creating-a-javascript-clock/
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="uxLogin.ascx.cs" Inherits="OmegaLove.Web.UI.uxLogin" %>
i need to implement this in the theTime textbox below or if there is another way that is great
i just want it working.
<div id="loginbox">
<asp:LoginView ID="LoginView1" runat="server">
<AnonymousTemplate>
<asp:Login ID="LoginStatus" runat="server" Height="31px" width="100%" FailureAction="RedirectToLoginPage"
onloggedin="LoginStatus_LoggedIn" onloggingin="LoginStatus_LoggingIn">
<LayoutTemplate>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td nowrap="nowrap" width="25%">
<asp:Label runat="server" ID="lblUserName" AssociatedControlID="UserName" Text="Username:" />
<asp:TextBox id="UserName" runat="server" BorderColor="DarkGray"
BorderStyle="Inset" BorderWidth="2px" Width="125px" />
</td>
<td width="8px" style="text-align: left;" valign="middle">
<asp:RequiredFieldValidator ID="valRequireUserName" runat="server" SetFocusOnError="True"
ControlToValidate="UserName" Text="*" ValidationGroup="Login"
Font-Bold="True" />
</td>
<td nowrap="nowrap" width="25%">
<asp:Label ID="lblPassword" runat="server" AssociatedControlID="Password" Text="Password:" />
<asp:TextBox ID="Password" runat="server" TextMode="Password"
BorderColor="DarkGray" BorderStyle="Inset" BorderWidth="2px"
Width="125px" />
</td>
<td width="8px" style="text-align: left;" valign="middle">
<asp:RequiredFieldValidator ID="valRequirePassword" runat="server"
ControlToValidate="Password" SetFocusOnError="True" Text="*"
ValidationGroup="Login" Font-Bold="True" />
</td>
<td width="25%">
<asp:Button CssClass="button-login" validationgroup="Login"
CommandName="Login" ID="btnLogin"
runat="server" Text="Login" Font-Bold="True" />
</td>
</tr>
<tr>
<td width="100%" colspan="5" style="text-align: right;">
<asp:HyperLink ID="lnkRegister" runat="server" NavigateUrl="~/Secure/Register.aspx">Create New Account
</asp:HyperLink>
| <asp:HyperLink ID="lnkPasswordRecovery" runat="server"
NavigateUrl="~/Secure/PasswordRecovery.aspx">Forgot
password?</asp:HyperLink>
</td>
</tr>
<tr>
<td width="100%" colspan="5" style="text-align: right;">
<asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
<input type="text" class="value" name="theTime" size="27" readonly="readonly" style="border: 0px;">
</td>
</tr>
</table>
</LayoutTemplate>
</asp:Login>
</AnonymousTemplate>
<LoggedInTemplate>
<div id="welcomebox">
<asp:LoginName ID="LoginName1" runat="server" FormatString="Welcome {0}" />
<asp:Button CssClass="button-login" ID="btnLogout" runat="server" Text="Logout" Font-Bold="True"
OnClick="btnLogout_Click" /><br />
<input type="text" class="value" name="theTime" size="27" readonly="readonly" style="border: 0px;">
</div>
</LoggedInTemplate>
</asp:LoginView>
</div>
ASKER
'document.getElementById(. ..)' is null or not an object
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head><title>
</title><link href="App_Themes/PlainHtml /Commented .css" type="text/css" rel="stylesheet" /><link href="App_Themes/PlainHtml /Default.c ss" type="text/css" rel="stylesheet" /><link href="App_Themes/PlainHtml /Print.css " type="text/css" rel="stylesheet" /><link href="App_Themes/PlainHtml /StyleLayo ut.css" type="text/css" rel="stylesheet" /><link href="App_Themes/PlainHtml /StyleShee t.css" type="text/css" rel="stylesheet" /><link href="App_Themes/PlainHtml /TabView.c ss" type="text/css" rel="stylesheet" /></head>
<body>
<form method="post" action="WebForm3.aspx" onsubmit="javascript:retur n WebForm_OnSubmit();" id="form1">
<div>
<input type="hidden" name="__LASTFOCUS" id="__LASTFOCUS" value="" />
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTQyNTYwNzA 5NGRk7SMwN pjow2dh1w2 Bpq982GtHc KQ=" />
</div>
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['form1'];
if (!theForm) {
theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.valu e = eventTarget;
theForm.__EVENTARGUMENT.va lue = eventArgument;
theForm.submit();
}
}
//]]>
</script>
<script src="/WebResource.axd?d=ku JdcXdIl8rh V6ERZYH5bg 2&t=63 3595156183 430636" type="text/javascript"></s cript>
<script src="/WebResource.axd?d=C7 tNH0ii8Hjn Xcc78mYxte 6OgsA2zjvS 8IkfoCVVIS E1&t=6 3359515618 3430636" type="text/javascript"></s cript>
<script src="/WebResource.axd?d=rx uiwK0usmvL cZJD7TjJnA 2&t=63 3595156183 430636" type="text/javascript"></s cript>
<script type="text/javascript">
//<![CDATA[
function WebForm_OnSubmit() {
if (typeof(ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) return false;
return true;
}
//]]>
</script>
<div>
<input type="hidden" name="__SCROLLPOSITIONX" id="__SCROLLPOSITIONX" value="0" />
<input type="hidden" name="__SCROLLPOSITIONY" id="__SCROLLPOSITIONY" value="0" />
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWBALm8aOVCQLKpae YDgLDici3D wKvi+2dATC wpzbv1EDRG SEZ6caDFzL bEZCL" />
</div>
<div>
<script type="text/javascript">
<!--
function updateClock() {
var currentTime = new Date();
var currentHours = currentTime.getHours();
var currentMinutes = currentTime.getMinutes();
var currentSeconds = currentTime.getSeconds();
// Pad the minutes and seconds with leading zeros, if required
currentMinutes = (currentMinutes < 10 ? "0" : "") + currentMinutes;
currentSeconds = (currentSeconds < 10 ? "0" : "") + currentSeconds;
// Choose either "AM" or "PM" as appropriate
var timeOfDay = (currentHours < 12) ? "AM" : "PM";
// Convert the hours component to 12-hour format if needed
currentHours = (currentHours > 12) ? currentHours - 12 : currentHours;
// Convert an hours component of "0" to "12"
currentHours = (currentHours == 0) ? 12 : currentHours;
// Compose the string for display
var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay;
// Update the time display
//document.getElementById( "clock").f irstChild. nodeValue = currentTimeString;
document.getElementById("c lock").val ue = currentTimeString;
}
window.onload = function() {
setInterval('updateClock() ', 1000);
}
// -->
</script>
<div id="loginbox">
<table id="uxLogin1_LoginView1_Lo ginStatus" cellspacing="0" cellpadding="0" border="0" style="height:31px;width:1 00%;border -collapse: collapse;" >
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td nowrap="nowrap" width="25%">
<label for="uxLogin1_LoginView1_L oginStatus _UserName" id="uxLogin1_LoginView1_Lo ginStatus_ lblUserNam e">Usernam e:</label>
<input name="uxLogin1$LoginView1$ LoginStatu s$UserName " type="text" id="uxLogin1_LoginView1_Lo ginStatus_ UserName" style="border-color:DarkGr ay;border- width:2px; border-sty le:Inset;w idth:125px ;" />
</td>
<td width="8px" style="text-align: left;" valign="middle">
<span id="uxLogin1_LoginView1_Lo ginStatus_ valRequire UserName" style="color:Red;font-weig ht:bold;vi sibility:h idden;">*< /span>
</td>
<td nowrap="nowrap" width="25%">
<label for="uxLogin1_LoginView1_L oginStatus _Password" id="uxLogin1_LoginView1_Lo ginStatus_ lblPasswor d">Passwor d:</label>
<input name="uxLogin1$LoginView1$ LoginStatu s$Password " type="password" id="uxLogin1_LoginView1_Lo ginStatus_ Password" style="border-color:DarkGr ay;border- width:2px; border-sty le:Inset;w idth:125px ;" />
</td>
<td width="8px" style="text-align: left;" valign="middle">
<span id="uxLogin1_LoginView1_Lo ginStatus_ valRequire Password" style="color:Red;font-weig ht:bold;vi sibility:h idden;">*< /span>
</td>
<td width="25%">
<input type="submit" name="uxLogin1$LoginView1$ LoginStatu s$btnLogin " value="Login" onclick="javascript:WebFor m_DoPostBa ckWithOpti ons(new WebForm_PostBackOptions(&q uot;uxLogi n1$LoginVi ew1$LoginS tatus$btnL ogin" , "", true, "Login", "", false, false))" id="uxLogin1_LoginView1_Lo ginStatus_ btnLogin" class="button-login" style="font-weight:bold;" />
</td>
</tr>
<tr>
<td width="100%" colspan="5" style="text-align: right;">
<a id="uxLogin1_LoginView1_Lo ginStatus_ lnkRegiste r" href="Secure/Register.aspx ">Create New Account
</a>
| <a id="uxLogin1_LoginView1_Lo ginStatus_ lnkPasswor dRecovery" href="Secure/PasswordRecov ery.aspx"> Forgot
password?</a>
</td>
</tr>
<tr>
<td width="100%" colspan="5" style="text-align: right;">
<input type="text" class="value" name="clock" size="27" readonly="readonly" style="border: 0px;">
</td>
</tr>
</table>
</td>
</tr>
</table>
0
</div>
</div>
<script type="text/javascript">
//<![CDATA[
var Page_Validators = new Array(document.getElementB yId("uxLog in1_LoginV iew1_Login Status_val RequireUse rName"), document.getElementById("u xLogin1_Lo ginView1_L oginStatus _valRequir ePassword" ));
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
var uxLogin1_LoginView1_LoginS tatus_valR equireUser Name = document.all ? document.all["uxLogin1_Log inView1_Lo ginStatus_ valRequire UserName"] : document.getElementById("u xLogin1_Lo ginView1_L oginStatus _valRequir eUserName" );
uxLogin1_LoginView1_LoginS tatus_valR equireUser Name.contr oltovalida te = "uxLogin1_LoginView1_Login Status_Use rName";
uxLogin1_LoginView1_LoginS tatus_valR equireUser Name.focus OnError = "t";
uxLogin1_LoginView1_LoginS tatus_valR equireUser Name.valid ationGroup = "Login";
uxLogin1_LoginView1_LoginS tatus_valR equireUser Name.evalu ationfunct ion = "RequiredFieldValidatorEva luateIsVal id";
uxLogin1_LoginView1_LoginS tatus_valR equireUser Name.initi alvalue = "";
var uxLogin1_LoginView1_LoginS tatus_valR equirePass word = document.all ? document.all["uxLogin1_Log inView1_Lo ginStatus_ valRequire Password"] : document.getElementById("u xLogin1_Lo ginView1_L oginStatus _valRequir ePassword" );
uxLogin1_LoginView1_LoginS tatus_valR equirePass word.contr oltovalida te = "uxLogin1_LoginView1_Login Status_Pas sword";
uxLogin1_LoginView1_LoginS tatus_valR equirePass word.focus OnError = "t";
uxLogin1_LoginView1_LoginS tatus_valR equirePass word.valid ationGroup = "Login";
uxLogin1_LoginView1_LoginS tatus_valR equirePass word.evalu ationfunct ion = "RequiredFieldValidatorEva luateIsVal id";
uxLogin1_LoginView1_LoginS tatus_valR equirePass word.initi alvalue = "";
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
var Page_ValidationActive = false;
if (typeof(ValidatorOnLoad) == "function") {
ValidatorOnLoad();
}
function ValidatorOnSubmit() {
if (Page_ValidationActive) {
return ValidatorCommonOnSubmit();
}
else {
return true;
}
}
theForm.oldSubmit = theForm.submit;
theForm.submit = WebForm_SaveScrollPosition Submit;
theForm.oldOnSubmit = theForm.onsubmit;
theForm.onsubmit = WebForm_SaveScrollPosition OnSubmit;
WebForm_AutoFocus('uxLogin 1_LoginVie w1_LoginSt atus_UserN ame');//]] >
</script>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head><title>
</title><link href="App_Themes/PlainHtml
<body>
<form method="post" action="WebForm3.aspx" onsubmit="javascript:retur
<div>
<input type="hidden" name="__LASTFOCUS" id="__LASTFOCUS" value="" />
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTQyNTYwNzA
</div>
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['form1'];
if (!theForm) {
theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.valu
theForm.__EVENTARGUMENT.va
theForm.submit();
}
}
//]]>
</script>
<script src="/WebResource.axd?d=ku
<script src="/WebResource.axd?d=C7
<script src="/WebResource.axd?d=rx
<script type="text/javascript">
//<![CDATA[
function WebForm_OnSubmit() {
if (typeof(ValidatorOnSubmit)
return true;
}
//]]>
</script>
<div>
<input type="hidden" name="__SCROLLPOSITIONX" id="__SCROLLPOSITIONX" value="0" />
<input type="hidden" name="__SCROLLPOSITIONY" id="__SCROLLPOSITIONY" value="0" />
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWBALm8aOVCQLKpae
</div>
<div>
<script type="text/javascript">
<!--
function updateClock() {
var currentTime = new Date();
var currentHours = currentTime.getHours();
var currentMinutes = currentTime.getMinutes();
var currentSeconds = currentTime.getSeconds();
// Pad the minutes and seconds with leading zeros, if required
currentMinutes = (currentMinutes < 10 ? "0" : "") + currentMinutes;
currentSeconds = (currentSeconds < 10 ? "0" : "") + currentSeconds;
// Choose either "AM" or "PM" as appropriate
var timeOfDay = (currentHours < 12) ? "AM" : "PM";
// Convert the hours component to 12-hour format if needed
currentHours = (currentHours > 12) ? currentHours - 12 : currentHours;
// Convert an hours component of "0" to "12"
currentHours = (currentHours == 0) ? 12 : currentHours;
// Compose the string for display
var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay;
// Update the time display
//document.getElementById(
document.getElementById("c
}
window.onload = function() {
setInterval('updateClock()
}
// -->
</script>
<div id="loginbox">
<table id="uxLogin1_LoginView1_Lo
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td nowrap="nowrap" width="25%">
<label for="uxLogin1_LoginView1_L
<input name="uxLogin1$LoginView1$
</td>
<td width="8px" style="text-align: left;" valign="middle">
<span id="uxLogin1_LoginView1_Lo
</td>
<td nowrap="nowrap" width="25%">
<label for="uxLogin1_LoginView1_L
<input name="uxLogin1$LoginView1$
</td>
<td width="8px" style="text-align: left;" valign="middle">
<span id="uxLogin1_LoginView1_Lo
</td>
<td width="25%">
<input type="submit" name="uxLogin1$LoginView1$
</td>
</tr>
<tr>
<td width="100%" colspan="5" style="text-align: right;">
<a id="uxLogin1_LoginView1_Lo
</a>
| <a id="uxLogin1_LoginView1_Lo
password?</a>
</td>
</tr>
<tr>
<td width="100%" colspan="5" style="text-align: right;">
<input type="text" class="value" name="clock" size="27" readonly="readonly" style="border: 0px;">
</td>
</tr>
</table>
</td>
</tr>
</table>
0
</div>
</div>
<script type="text/javascript">
//<![CDATA[
var Page_Validators = new Array(document.getElementB
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
var uxLogin1_LoginView1_LoginS
uxLogin1_LoginView1_LoginS
uxLogin1_LoginView1_LoginS
uxLogin1_LoginView1_LoginS
uxLogin1_LoginView1_LoginS
uxLogin1_LoginView1_LoginS
var uxLogin1_LoginView1_LoginS
uxLogin1_LoginView1_LoginS
uxLogin1_LoginView1_LoginS
uxLogin1_LoginView1_LoginS
uxLogin1_LoginView1_LoginS
uxLogin1_LoginView1_LoginS
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
var Page_ValidationActive = false;
if (typeof(ValidatorOnLoad) == "function") {
ValidatorOnLoad();
}
function ValidatorOnSubmit() {
if (Page_ValidationActive) {
return ValidatorCommonOnSubmit();
}
else {
return true;
}
}
theForm.oldSubmit = theForm.submit;
theForm.submit = WebForm_SaveScrollPosition
theForm.oldOnSubmit = theForm.onsubmit;
theForm.onsubmit = WebForm_SaveScrollPosition
WebForm_AutoFocus('uxLogin
</script>
</form>
</body>
</html>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="uxLogin.ascx.cs" Inherits="OmegaLove.Web.UI.uxLogin" %>
<script type="text/javascript">
<!--
function updateClock() {
var currentTime = new Date();
var currentHours = currentTime.getHours();
var currentMinutes = currentTime.getMinutes();
var currentSeconds = currentTime.getSeconds();
// Pad the minutes and seconds with leading zeros, if required
currentMinutes = (currentMinutes < 10 ? "0" : "") + currentMinutes;
currentSeconds = (currentSeconds < 10 ? "0" : "") + currentSeconds;
// Choose either "AM" or "PM" as appropriate
var timeOfDay = (currentHours < 12) ? "AM" : "PM";
// Convert the hours component to 12-hour format if needed
currentHours = (currentHours > 12) ? currentHours - 12 : currentHours;
// Convert an hours component of "0" to "12"
currentHours = (currentHours == 0) ? 12 : currentHours;
// Compose the string for display
var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay;
// Update the time display
//document.getElementById("clock").firstChild.nodeValue = currentTimeString;
document.getElementById("clock").value = currentTimeString;
}
window.onload = function() {
setInterval('updateClock()', 1000);
}
// -->
</script>
<div id="loginbox">
<asp:LoginView ID="LoginView1" runat="server">
<AnonymousTemplate>
<asp:Login ID="LoginStatus" runat="server" Height="31px" width="100%" FailureAction="RedirectToLoginPage"
onloggedin="LoginStatus_LoggedIn" onloggingin="LoginStatus_LoggingIn">
<LayoutTemplate>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td nowrap="nowrap" width="25%">
<asp:Label runat="server" ID="lblUserName" AssociatedControlID="UserName" Text="Username:" />
<asp:TextBox id="UserName" runat="server" BorderColor="DarkGray"
BorderStyle="Inset" BorderWidth="2px" Width="125px" />
</td>
<td width="8px" style="text-align: left;" valign="middle">
<asp:RequiredFieldValidator ID="valRequireUserName" runat="server" SetFocusOnError="True"
ControlToValidate="UserName" Text="*" ValidationGroup="Login"
Font-Bold="True" />
</td>
<td nowrap="nowrap" width="25%">
<asp:Label ID="lblPassword" runat="server" AssociatedControlID="Password" Text="Password:" />
<asp:TextBox ID="Password" runat="server" TextMode="Password"
BorderColor="DarkGray" BorderStyle="Inset" BorderWidth="2px"
Width="125px" />
</td>
<td width="8px" style="text-align: left;" valign="middle">
<asp:RequiredFieldValidator ID="valRequirePassword" runat="server"
ControlToValidate="Password" SetFocusOnError="True" Text="*"
ValidationGroup="Login" Font-Bold="True" />
</td>
<td width="25%">
<asp:Button CssClass="button-login" validationgroup="Login"
CommandName="Login" ID="btnLogin"
runat="server" Text="Login" Font-Bold="True" />
</td>
</tr>
<tr>
<td width="100%" colspan="5" style="text-align: right;">
<asp:HyperLink ID="lnkRegister" runat="server" NavigateUrl="~/Secure/Register.aspx">Create New Account
</asp:HyperLink>
| <asp:HyperLink ID="lnkPasswordRecovery" runat="server"
NavigateUrl="~/Secure/PasswordRecovery.aspx">Forgot
password?</asp:HyperLink>
</td>
</tr>
<tr>
<td width="100%" colspan="5" style="text-align: right;">
<asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
<input type="text" class="value" name="clock" size="27" readonly="readonly" style="border: 0px;">
</td>
</tr>
</table>
</LayoutTemplate>
</asp:Login>
</AnonymousTemplate>
<LoggedInTemplate>
<div id="welcomebox">
<asp:LoginName ID="LoginName1" runat="server" FormatString="Welcome {0}" />
<asp:Button CssClass="button-login" ID="btnLogout" runat="server" Text="Logout" Font-Bold="True"
OnClick="btnLogout_Click" /><br />
<input type="text" class="value" name="clock" size="27" readonly="readonly" style="border: 0px;">
</div>
</LoggedInTemplate>
</asp:LoginView>
</div>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
awesome
You just need to put one control inside the ascx page to display the clock time that mentioned in the article.
You can arrange the textbox - "clock" based on your preferred position.
Here is the attempt:
</script>
function updateClock ( )
{
var currentTime = new Date ( );
var currentHours = currentTime.getHours ( );
var currentMinutes = currentTime.getMinutes ( );
var currentSeconds = currentTime.getSeconds ( );
// Pad the minutes and seconds with leading zeros, if required
currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;
// Choose either "AM" or "PM" as appropriate
var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";
// Convert the hours component to 12-hour format if needed
currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;
// Convert an hours component of "0" to "12"
currentHours = ( currentHours == 0 ) ? 12 : currentHours;
// Compose the string for display
var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay;
// Update the time display (Change the control name here)
document.getElementById("c
}
window.onload=function(){
setInterval('updateClock()
}
</script>
<input type=text ID="clock" style="border:0"/>
<div id="loginbox">
....