ASP.NET避免页面重新整理时重复发送...
我们可以继承 ASP.NET 的 Page 类别,自行扩充所需的功能!作法如下:
1、继承 System.Web.UI.Page,自订一个 BasePage 类别。
以下为引用的内容:
using
System;
/// <summary>
/// BasePage 的摘要描述
/// </summary>
public
class
BasePage : System.Web.UI.Page
{
public
BasePage() { }
}
2、在 BasePage 类别底下撰写 SetActionStamp 方法,目的是在 Session 存放一个系统时间戳记。
以下为引用的内容:
/// <summary>
/// 設置戳記
/// </summary>
private
void
SetActionStamp()
{
Session[
"actionStamp"
] = Server.UrlEncode(DateTime.Now.ToString());
}
3、处理 PreRender 事件,在网页初次载入时设置戳记,且每次载入执行时会把该戳记存放到 HiddenField 里。
以下为引用的内容:
public
BasePage() {
this
.PreRender +=
new
EventHandler(Page_PreRender); }
void
Page_PreRender(
object
sender, EventArgs e)
{
if
(!IsPostBack)
{
SetActionStamp();
}
ClientScript.RegisterHiddenField(
"actionStamp"
, Session[
"actionStamp"
].ToString());
}
4、自订 IsRefresh 属性,藉由判断 HiddenField 存放的戳记是否等于 Session
裡存放的值,就可以得知网页是否经由重新整理动作回传。
以下为引用的
相关文档:
<asp:TemplateField HeaderText="测试">
<ItemTemplate>
<asp:LinkButton ID="test" runat="server" OnClick="test_Click" OnClientClick='<%# string.Format("return confirmDelete(\"{0} {1}\");", DoEscape((string)Eval( ......
上次我们说到的编译成的dll文件与cs文件在同一目录中,而不会放到虚拟目录的bin目录中,如何做才能够把cs
文件编译成dll且自动放到虚拟目录的bin文件夹中呢?
开始-------程序-------Microsoft Visual Studio.NET 2003-------Visual Studio.NET工具,点击其中的“Visual Studio.NET2003命令提示”,就会进入Mic ......
一、(单值绑定)在页面的后台代码中定义公有变量,如下:
public string gongYou = "声明的公有成员";
①然后在页面的源中调用,如下:
<asp:Label ID="lblMgs" runat="server" Text="<%#gongYou >"></asp:Label>
②当然最后要记得绑定数据:
protected void Page_Load(object ......
Request.ServerVariables["Url"]
返回服务器地址
Request.ServerVariables["Path_Info"]
客户端提供的路径信息
Request.ServerVariables["Appl_Physical_Path"]
与应用程序元数据库路径相应的物理路径
Request.ServerVariables["Path_Translated"]
通过由虚拟至物理的映射后得到的路径
Request.ServerVariables ......