欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

asp.net 實(shí)現(xiàn)動(dòng)態(tài)顯示當(dāng)前時(shí)間(不用javascript不考慮開銷)

 更新時(shí)間:2009年11月03日 23:50:39   作者:  
asp.net實(shí)現(xiàn)動(dòng)態(tài)顯示時(shí)間,無需用到j(luò)avascrip,而是用了AJAX。
Default.aspx頁面:先拉一個(gè)ScriptManager控件到頁面,然后拉一個(gè)UpdatePanel控件。UpdatePanel里面放一個(gè)Label用于顯示時(shí)間,放一個(gè)timer控件用于控制時(shí)間的更新。注意Label與Label都要放到UpdatePanel控件里面。最后,timer控件的Interval屬性設(shè)置為1000,讓它每1秒執(zhí)行一次即更新時(shí)間。
Default.aspx.cs頁面:只需在
protected void Page_Load(object sender, EventArgs e)
里面輸入
Label1.Text = DateTime.Now.ToString();
即可。
下面是兩個(gè)頁面的源碼:
Default.aspx
復(fù)制代碼 代碼如下:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="動(dòng)態(tài)顯示實(shí)時(shí)時(shí)間._Default" %>
<!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>動(dòng)態(tài)顯示實(shí)時(shí)時(shí)間</title>
<style type="text/css">
.style1
{
height: 183px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div> <asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
</div>
<table style=" position: absolute; margin-left:200px; margin-right:200px; margin-top:100px; width:270px; height:78px; top: 15px; left: 10px;">
<tr>
<td>動(dòng)態(tài)顯示實(shí)時(shí)時(shí)間</td>
</tr>
<tr><td class="style1"><asp:UpdatePanel ID="UpdatePanel1" runat="server" >
<ContentTemplate>
當(dāng)前時(shí)間是:
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Timer ID="Timer1" runat="server" Interval="1000">
</asp:Timer>
</ContentTemplate>
</asp:UpdatePanel>
</td></tr>
</table>
</form>
</body>
</html>

Default.aspx.cs
復(fù)制代碼 代碼如下:

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace 動(dòng)態(tài)顯示實(shí)時(shí)時(shí)間
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.ToString();
}
}
}

相關(guān)文章

最新評(píng)論