SomeWebModelDialogTips

来源:互联网 发布:java scala actor 编辑:程序博客网 时间:2024/05/11 13:03
用Javascript 打开一个modalDialog时,IE常常会缓存这个Page。同时用XMLHttpRequest的Send进行请求的时候,IE也会缓存这个Page。如何解决?
(1) 在要打开或要请求的Url后面多加一个随机参数,来避免页面被缓存,随便加一个什么都行,只要每次都不一样。
var url = Page.aspx?Id=0&temp= + Math.random();
window.showModalDialog(url, , status:no; help:no;);
(2) 在该asp.net 页面的 Page_Load 方法里设定不缓存。
protected void Page_Load(object sender, EventArgs e){
Response.Expires = 0;
Response.Cache.SetNoStore();
Response.AppendHeader("Pragma", "no-cache");
}
或者
protected void Page_Load(object sender, EventArgs e){
this.Response.CacheControl = "no-cache";
}

如果这个modalDialog页面上有form.submit(),用Asp.Net开发时这个submit会在客户端打开一个新的IE,而不是在那个modalDialog上更新,这时候该怎么办?
(1) 需要给打开的那个modalDialog的父页面的Html的Head部分添加
<base target=_self></base> 这样一段话。

(2) 先实现一个模态对话框页面文件****Frame.aspx,在其中写上
<body>
<iframe width=600 height=400 name=aa frameborder=0 src="****Task.aspx"></iframe>
</body>
然后 实现****task.aspx页面文件,这个是真正提供用户内容输入和提交的页面。套的这个iframe帮忙做到了。