<%@ Page Language="VB" %>
<script runat="server">
Sub Page_Load
If Not IsPostBack Then
lblMessage.Text &= "<li>Init Load"
Else
lblMessage.Text &= "<li>PostBack"
End If
If radlSwitch.SelectedItem.Text = "Start" Then
txtHiddenDate.Attributes.Add("OnPropertyChange", GetPostBackEventReference(btnShowDate))
Else
txtHiddenDate.Attributes.Add("OnPropertyChange", "")
End If
End Sub
Sub btnShowDate_Click(s As Object, e As EventArgs)
lblDateTime.Text = DateTime.Now.AddHours(14).ToString()
End Sub
</script>
<html>
<head>
<title>AuotPostBack2.aspx</title>
<script language="javascript">
function autoPostBack(){
document.all('txtHiddenDate').value=new Date();
}
</script>
</head>
<body onLoad="setTimeout('autoPostBack()',1000)">
<form id="form1" runat="server">
<b>AutoPostBack:</b>
<asp:RadioButtonList id="radlSwitch" runat="server"
AutoPostBack="True"
RepeatDirection="Horizontal">
<asp:ListItem Text="Start" />
<asp:ListItem Text="Stop" Selected="True" />
</asp:RadioButtonList>
<p>
<b>Current Date and Time:</b><br>
<asp:Label id="lblDateTime" runat="server" />
<p>
<asp:TextBox id="txtHiddenDate" runat="server"
Text="Hidden" Width="0"
AutoPostBack="True" />
<asp:button id="btnShowDate" runat="server"
Text="Hidden"
Visible="False"
OnClick="btnShowDate_Click" />
<hr>
<ol>
<asp:Label id="lblMessage" runat="server" />
</ol>
</form>
</body>
</html>
|