完成一个页面操作后,要更新另一个界面,怎么弄啊????说话算数解决就给分 我在1.aspx中有一个DropDownList控件邦定了数据库当我点击1.aspx中的一个button时,弹出一个窗口(2.aspx),我添加信息,然后关闭该窗口(2.aspx),就可以在1.aspx中的DropDownList 中得到我添加的信息。谢谢帮忙!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 关闭子窗口的同时刷新父窗口Response.Write("<script>alert('添加成功!');opener.location.href=opener.location.href;close();</script>");刷新爷爷窗口window.opener.opener.location.href='a.aspx' 用模态窗口,可以有一个返回值,将这个返回值添加进DropDownList中就可以了 function Goto(strUrl){ str=window.showModalDialog(strUrl,'','dialogheight :300px; dialogwidth :700px; edge: Raised; center: Yes; help: No; resizable: No; status: No; scroll:No;'); //alert(str) if(str =='0') { // alert('操作失败'); return false; } else if(str=='1') { // alert('操作成功'); // document.all.btnRef.focus(); //alert('focus'); document.all.btnRef.click(); //alert('click'); return false; } } 刷新父窗口的时候重绑一下DropDownList 的数据源 btnRef是一个width=0的按钮,你可以在这个单击事件里面把添加的东西insert进去 time_is_life(今夜太冷)的方法可能会造成服务器端不能得到绑定的值,因为在从数据库对DropDownList进行绑定的时候,没有新增加的项。如果要使用,可能需要一些辅助的控件,比如隐藏域呀什么的。简单一点,重新绑定。 这个倒不一定要刷新主页面,完全用javascript实现也可以<script language="javascript">function returnInput() { var tmp = document.getElementById("TextBox1").value; var oOption = opener.window.document.createElement("OPTION"); oOption.innerText = tmp; oOption.value = tmp; var ddlst = opener.window.document.getElementById("DropDownList1"); ddlst.options.add(oOption); window.opener = null; window.close(); }</script><INPUT onclick="returnInput();" style="Z-INDEX: 107; LEFT: 416px; POSITION: absolute; TOP: 152px" type="button" value="Button" id="Button2" name="Button2"> 这个倒不一定要刷新主页面,完全用javascript实现也可以<script language="javascript">function returnInput() { var tmp = document.getElementById("TextBox1").value; var oOption = opener.window.document.createElement("OPTION"); oOption.innerText = tmp; oOption.value = tmp; var ddlst = opener.window.document.getElementById("DropDownList1"); ddlst.options.add(oOption); window.opener = null; window.close(); }</script><INPUT onclick="returnInput();" style="Z-INDEX: 107; LEFT: 416px; POSITION: absolute; TOP: 152px" type="button" value="Button" id="Button2" name="Button2"> To:Tom_Real() 我是想重新绑定我怎么在2.aspx中调用1.aspx中的DropDownList控件阿?我曾试着把DropDownList设置为public在2.aspx中声明一个1.aspx类的实例a,用a.DropDownList.dataSource=ds;但是出错!应该怎么写啊??? To:fphuang(人在哈尔滨) 你的方法很好,但在出现“添加成功”时后面页面变白能不能让他保持原态阿!还有opener.location.href=opener.location.href;这句是什么意思啊? 这就是关闭子窗口的同时刷新父窗口,就进行了数据绑定。Response.Write("<script>alert('添加成功!');opener.location.href=opener.location.href;close();</script>");都说得对。 用window.showModalDialog打开2.aspx,关闭后再返回服务器执行Button事情并在事件中重新绑定 这里是asp.net论坛耶,怎么一个个都喜欢全用javascript解决啊?在弹出页面的添加按钮下加个Session存储当前添加的值,而主页面则在Page_Load事件中加个if(Session[xxx]!=null){把Session中的信息加入到DDL中的代码;}OK了; 哦,忘了,加完之后,记得释放该Session; ASP。NET程式做得完美,少了Script是不可能的 这个当然,可事事用Script就不能了,就像这里,纯用javaScript,只不过能让用户当时看着高兴罢了,实际上什么信息也没留下,并且,HTML页面应该用来写其它更有用的javaScript代码,而不能浪费在这种小事情上;就算是用JS文件,写太多javaScript代码也不是什么好事(javaScript实在是太透明了)。 To:Belice(天下无风) 我要的是关闭此窗口就可以在父窗口中查到我添加的信息,关闭该窗口后都不调主窗口的Page_load();如果能调就好了! To:fphuang(人在哈尔滨) 你的方法很好,但在出现“添加成功”时后面页面变白能不能让他保持原态阿!还有opener.location.href=opener.location.href;这句是什么意思啊? 可以调用的,你只要在添加按钮后加个脚本添加就成了:Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script LANGUAGE=JavaScript>window.opener.window.document.forms(0).submit(); window.close();</script> ");其实就是让父窗口刷新(提交)一次 你们总用opener他的作用是什么啊?window.opener.window.document.forms(0).submit();这个可以分解的说明一下吗? ......window不用说了,opener指创建者,当前页面是从哪个页面弹出的就指哪个页面,后面的依次就是指opener的window的document的forms,执行提交方法.forms是页面中form的集合,第一个form,就是forms(0)了。 Response.Write("<script language=javascript>location.href='Mst_users_query.aspx?code="+Convert.ToInt64( Request.QueryString["code"] )+"';</script>"); To:Belice(天下无风)呵呵~~~~谢谢讲解! 为什么我的网页有的人可以打开有的人打不开? wuyq11 如何通过 ASPX 启动一个应用程序,并将结果返回页面 当某字段由1变为0时显示提示信息 datagrid编辑数据后出现begineidt() 请问利用asp.net如何读取EXCEL中某一列的值。 DATATABLE添加一行问题。 用 DirectorySearcher 执行查询,怎会出错? WEBFORM的两个问题!请各位帮忙。 怎么让显示的时间适时更新 许多公司都提供了多语言版本的网站以满足全球化的战略需要。?怎么程序实现? 可怕的异常
str=window.showModalDialog(strUrl,'','dialogheight :300px; dialogwidth :700px; edge: Raised; center: Yes; help: No; resizable: No; status: No; scroll:No;');
//alert(str)
if(str =='0')
{
// alert('操作失败');
return false;
}
else if(str=='1')
{
// alert('操作成功');
// document.all.btnRef.focus();
//alert('focus');
document.all.btnRef.click();
//alert('click');
return false;
}
}
DropDownList 的数据源
简单一点,重新绑定。
<script language="javascript">
function returnInput()
{
var tmp = document.getElementById("TextBox1").value;
var oOption = opener.window.document.createElement("OPTION");
oOption.innerText = tmp;
oOption.value = tmp;
var ddlst = opener.window.document.getElementById("DropDownList1");
ddlst.options.add(oOption);
window.opener = null;
window.close();
}
</script>
<INPUT onclick="returnInput();" style="Z-INDEX: 107; LEFT: 416px; POSITION: absolute; TOP: 152px"
type="button" value="Button" id="Button2" name="Button2">
<script language="javascript">
function returnInput()
{
var tmp = document.getElementById("TextBox1").value;
var oOption = opener.window.document.createElement("OPTION");
oOption.innerText = tmp;
oOption.value = tmp;
var ddlst = opener.window.document.getElementById("DropDownList1");
ddlst.options.add(oOption);
window.opener = null;
window.close();
}
</script>
<INPUT onclick="returnInput();" style="Z-INDEX: 107; LEFT: 416px; POSITION: absolute; TOP: 152px"
type="button" value="Button" id="Button2" name="Button2">
我是想重新绑定
我怎么在2.aspx中调用1.aspx中的DropDownList控件阿?我曾试着把DropDownList设置为public
在2.aspx中声明一个1.aspx类的实例a,用a.DropDownList.dataSource=ds;但是出错!
应该怎么写啊???
你的方法很好,但在出现“添加成功”时后面页面变白能不能让他保持原态阿!
还有opener.location.href=opener.location.href;这句是什么意思啊?
在弹出页面的添加按钮下加个Session存储当前添加的值,而主页面则在Page_Load事件中加个
if(Session[xxx]!=null)
{
把Session中的信息加入到DDL中的代码;
}
OK了;
我要的是关闭此窗口就可以在父窗口中查到我添加的信息,关闭该窗口后都不调主窗口的Page_load();如果能调就好了!
你的方法很好,但在出现“添加成功”时后面页面变白能不能让他保持原态阿!
还有opener.location.href=opener.location.href;这句是什么意思啊?
Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script LANGUAGE=JavaScript>window.opener.window.document.forms(0).submit(); window.close();</script> ");其实就是让父窗口刷新(提交)一次
window不用说了,opener指创建者,当前页面是从哪个页面弹出的就指哪个页面,后面的依次就是指opener的window的document的forms,执行提交方法.
forms是页面中form的集合,第一个form,就是forms(0)了。
呵呵~~~~谢谢讲解!