"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
html xmlns="http://www.w3.org/1999/xhtml"
head id="Head1" runat="server"
titlePageRequestManager beginRequest Example/title
style type="text/css"
body {
font-family: Tahoma;
}
div.AlertStyle
{
background-color: #FFC080;
top: 95%;
left: 1%;
height: 20px;
position: absolute;
visibility: hidden;
}
/style
(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/webkaifa/)/head
body
form id="form1" runat="server"
divasp:ScriptManager ID="ScriptManager1" runat="server" /
script type="text/javascript" language="javascript"
Sys.WebForms.PageRequestManager.getInstance(
).add_beginRequest(BeginRequestHandler);
Sys.WebForms.PageRequestManager.getInstance(
).add_endRequest(EndRequestHandler);
function BeginRequestHandler(sender, args)
{
var elem = args.get_postBackElement();
ActivateAlertDiv('visible', 'AlertDiv',
elem.value + '被单击, 正在获取系统时间');
}
function EndRequestHandler(sender, args)
{
ActivateAlertDiv('hidden', 'AlertDiv', '');
}
function ActivateAlertDiv(visstring, elem, msg)
{
var adiv = $get(elem);
adiv.style.visibility = visstring;
adiv.innerHTML = msg;
}
/script
asp:UpdatePanel ID="UpdatePanel1"
UpdateMode="Conditional" runat="Server"
ContentTemplate
asp:Panel ID="Panel1" runat="server"
GroupingText="Update Panel"
最后一次更新时间:
%= DateTime.Now.ToString()%.
br /
asp:Button runat="server" ID="Button1"
Text="第一个按钮" OnClick="ProcessClick_Handler" /
asp:Button runat="server" ID="Button2"
Text="第二个按钮" OnClick="ProcessClick_Handler" /
/asp:Panel
/ContentTemplate
/asp:UpdatePanel
div id="AlertDiv" class="AlertStyle"
/div/div/form/body
/html
3、Default.aspx.cs代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void ProcessClick_Handler(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(2000);
}}