是这样的,有一个列表页面,点列表中的一条信息就会弹出一个修改这条信息的对话框,可对这条信息修改,现在的效果是点完了修改,然后我就用this.colse();把这个弹出的修改窗口关闭了,可是原来的那个列表页面这条信息并没有刷新,需要手动刷新浏览器,想不用手动刷新怎么弄?
解决方案 »
- VS2008中MS Chart控件如何使用
- 生成静态页如何保证文章的格式 有图片的静态页是怎样生成的 在线等(问题解决,分全部归你)
- 新装了VS2008,出现"无法识别的配置节system.serviceModel. "
- 在类库项目文件中能否获取文件的绝对路径?
- 把DropDownList放在ajax的UpdatePanel里面,在Page_PreInit里会出错“未将对象引用设置到对象的实例。”,显示这个DropDownList是Nothing
- 我有一个数组 数组里面是 text控件的名字 请问如何用一个for循环获取到这些text的值。。
- ▃◣ 巨汗的 ASP 木马, 如何才能让它无法运行!
- Asp.net 中如何得到远程MAC地址
- TreeView的CheckBox的问题
- Repeater控件里的DataItem数据项为何NULL?明明已经绑定数据了
- 关于textbox与dropdownlist的高度
- |zyciis| 在写XML文本内容的时候要不要用CDATA呢?还是直接对字符进行转入就行了?
调用绑定数据的方法。把数据放在UpdataPanel中。
Response.Write("<script>parent.location.reload();</script>");
在前台页面中加入这段话
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager> --一定不能少 且只能添加一个
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddl省" runat="server">
</asp:DropDownList> -- 放省级的DropDownList
<asp:DropDownList ID="ddl市" runat="server">
</asp:DropDownList>-- 放市级的DropDownList </ContentTemplate>后台绑定方法不变
</asp:UpdatePanel>
在this.close();前面加parent.location.reload();这句话试一下吧。
opener.location.reload();</script>");
另外你的那个联动的还没解决??
次代码写在修改页面的window.close();前面
Microsoft JScript 运行时错误: 'opener.location' 为空或不是对象报错了
{
int businessAreaId = Convert.ToInt32(((LinkButton)sender).ToolTip);
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "OpenBusinessAreaMaintainWindow", "<script language=javascript>window.showModalDialog('BusinessAreaMaintain.aspx?UserId=" + this.UserId + "&BusinessAreaId=" + businessAreaId + "', window, 'dialogWidth=500px;dialogHeight=500px;status=no;scroll=no;resizable=no;');</script>");
//Response.Redirect(Request.Url.ToString());
}
这个是弹出这个修改页面的后台代码
且 弹出的页面 用 window.open()方法打开
{
int businessAreaId = Convert.ToInt32(((LinkButton)sender).ToolTip);
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "OpenBusinessAreaMaintainWindow", "<script language=javascript>window.showModalDialog('BusinessAreaMaintain.aspx?UserId=" + this.UserId + "&BusinessAreaId=" + businessAreaId + "', window, 'dialogWidth=500px;dialogHeight=500px;status=no;scroll=no;resizable=no;');window.opener.location.reload();</script>");
}改成上面的试试
window.open(url, " ", "height=550,width=500,status=no,toolbar=no,menubar=no,location=no,resizable=yes,top=200px,left=300px ");你如果在列表页面用一个连接跳到你的修改页面
当然会报Microsoft JScript 运行时错误: 'opener.location' 为空或不是对象报错了
然后在关闭这个子页面时,执行如下一句js
window.opener.location.href=window.opener.location.href;
<a href='#' onclick="javascript:var=window.open('B页面.aspx?id=参数',null,'width=600,height=300')">修改</a>B页面:
在<head></head>中间加上这个<base target="_self" />
还有这个
<script language="javascript" type="text/javascript">
function reshow()
{
window.opener.location.reload();
}
</script>然后在<body>中加上这个:
<body onunload="reshow()">------------------------------------------------------------
这样修改信息后就可以刷新父窗体并且关闭子窗体Response.Write("<script>alert('更新成功!');window.close();</script>");
希望可以看懂
?id=参数1&&name=参数2
//父页面
function a(id) {
var v = window.showModalDialog("SqlEdit.aspx?id=" + id + "", "" + id + "", "dialogWidth:450px;dialogHeight:300px;dialogTop:230;center:yes;help:no;status:no;scroll:no;");
if (v) {
refresh();
}
} function refresh() {
//alert(document.getElementById("flag").value);
this.location = this.location;
}//子页面关闭按钮
<asp:Button ID="btnClose" runat="server" Text="关闭" Width="63px" OnClientClick="window.close()"
BorderStyle="Groove" />//子页面提交后台代码
Response.Write("<script>parent.window.returnValue=true;window.opener=null;window.close();</script>");
Request.QueryString["id1"] id1的值Request.QueryString["id2"] id2的值你还真是要让人送佛送到西啊。。
后置代码
保存事件中
Response.Redirect("页面");
lz现在做什么呢??经常能看到你...
function window.onbeforeunload()
{
window.opener.location.href = window.opener.location.href;
if (window.opener.progressWindow)
{
window.opener.progressWindow.close();
}
}
贴出来了,希望对你有用
<script>
function window.onbeforeunload()
{
window.opener.location.href = window.opener.location.href;
if (window.opener.progressWindow)
{
window.opener.progressWindow.close();
}
}
</script>
呗,完事,很方便
protected void lbtnName_Click(object sender, EventArgs e)
{
int businessAreaId = Convert.ToInt32(((LinkButton)sender).ToolTip);
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "OpenBusinessAreaMaintainWindow", "<script language=javascript>window.showModalDialog('BusinessAreaMaintain.aspx?UserId=" + this.UserId + "&BusinessAreaId=" + businessAreaId + "', window, 'dialogWidth=500px;dialogHeight=500px;status=no;scroll=no;resizable=no;');window.location.href=window.location.href;</script>");
}用这个!
{
int businessAreaId = Convert.ToInt32(((LinkButton)sender).ToolTip);
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "OpenBusinessAreaMaintainWindow", "<script language=javascript>window.showModalDialog('BusinessAreaMaintain.aspx?UserId=" + this.UserId + "&BusinessAreaId=" + businessAreaId + "', window, 'dialogWidth=500px;dialogHeight=500px;status=no;scroll=no;resizable=no;');window.location.href=window.location.href;</script>");
}
这样肯定行,我遇到过这种情况
/// 刷新父窗口,关闭当前窗口
/// </summary>
/// <param name="url"></param>
/// <param name="page"></param>
public static void RefreshParent(string url, Page page)
{
string js = @"<Script language='JavaScript'>
window.opener.location.href='" + url + "';alert('保存成功!');window.close();</Script>";
HttpContext.Current.Response.Write(js);
if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), "RefreshParent"))
{
page.ClientScript.RegisterStartupScript(page.GetType(), "RefreshParent", js);
}
}
this.clientScript.RegisterClientScriptBlock(this.GetType(),"Edit","alert('修改成功!');window.openner.document.getElementByID('cmdReflesh()').click()",true);
注:cmdReflesh为Button的ID
也就是说必须用window.open();打开吗?要是必须用window.open()打开,那怎么用window.open()传递两个参数???我不知道怎么传递两个参数用window.open(),别和我说是 参数1&参数2 啊
刚才写错了代码了,那个是刷新本页的
如果不用这种window.open();的方式可以穿两个,可是这样穿完两个,后面有会报我说的那个错,我都纠结了,我放弃了,不让它往外弹出了,直接跳转