62,050
社区成员
发帖
与我相关
我的任务
分享
<%@ Control Language="C#" %>
<script runat="server">
public int 点击按钮后等待的秒数
{
get
{
EnsureChildControls();
return this.Timer1.Interval / 1000;
}
set
{
EnsureChildControls();
this.Timer1.Interval = value * 1000;
}
}
public string 按钮文字
{
get
{
EnsureChildControls();
return this.Button1.Text;
}
set
{
EnsureChildControls();
this.Button1.Text = value;
}
}
public event EventHandler<EventArgs> 到时间提醒;
protected void Button1_Click(object sender, EventArgs e)
{
this.Timer1.Enabled = true;
}
protected void Timer1_Tick(object sender, EventArgs e)
{
Timer1.Enabled = false;
if (this.到时间提醒 != null)
this.到时间提醒(this, EventArgs.Empty);
}
</script>
<asp:Button ID="Button1" runat="server" Text="定时" OnClick="Button1_Click" />
<asp:Timer ID="Timer1" runat="server" Enabled="False" OnTick="Timer1_Tick" />
<%@ Page Language="C#" %>
<script runat="server">
protected void aa(object sender, EventArgs e)
{
this.Label1.Visible = false;
this.TestTimerControl1.Visible = false;
}
protected void bb(object sender, EventArgs e)
{
this.Label2.Text = DateTime.Now.ToLongTimeString();
}
</script>
<%@ Register Src="TestTimerControl.ascx" TagName="TestTimerControl" TagPrefix="uc1" %>
<!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 runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Label-1"></asp:Label>
<uc1:TestTimerControl ID="TestTimerControl1" runat="server" 点击按钮后等待的秒数="3" 按钮文字="隐藏"
On到时间提醒="aa" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="Label2" runat="server" Text="Label-2"></asp:Label>
<uc1:TestTimerControl ID="TestTimerControl2" runat="server" 点击按钮后等待的秒数="2" 按钮文字="显示现在的时间"
On到时间提醒="bb" />
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>