关于asp.net中页面间传值问题。急!!! 在asp.net中有两个页面:a.aspx和b.aspx。在a.aspx页面中有一个textbox(tb_reader)和一个button控件。当点击button按钮时进入b.aspx页面用来选取值。当点击b.aspx中的确定按钮时,选中的值(depart)就传到a.aspx中的textbox中。也就是:tb_reader.Text=depart的值。这应当如何来实现呢?高手帮忙啊!!!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在父窗口a.aspx中open在子窗口b.aspx中opener session 不可以。因为我想要两次用到a.aspx smalling可以给我一个例子吗?谢谢!! 还有补充一点就是当点击了b.aspx中的确定后关闭b这时值就直接传到a中。 网上转的方法一:使用showModalDialog方法新建文件lyh.html输入 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title></title></head><body><input type="button" onclick="show('lyhshow.html')" value="弹出窗口"><br><br><br>返回值:<input type="text" id="returnvalue"><script language="javascript">function show(math){var val= showModalDialog(math,"true", "dialogWidth:300px;dialogHeight:250px;status:no;help:no;");if(!val){return;}else{document.all.returnvalue.value=val;}}</script></body></html>新建文件lyhshow.html输入<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>来自Eric空间</title></head><body>请输入:<input type="text" id="txtValue" value=""><br><br><br><input type="button" onclick="ReturnValue()" value="返回输入值"><script language="javascript">function ReturnValue(){window.returnValue=document.all.txtValue.value;window.close();}</script></body></html>方法二:用window.open弹出窗口新建文件lyh2.html输入<head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>来自Eric空间</title></head><body><input type="button" onclick="show('lyhshow2.html')" value="弹出窗口"><br><br><br>返回值:<input type="text" id="returnvalue"><script language="javascript"><!-- function show(math){window.open (math,'newwindow','height=250,width=300,top=300,left=300,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no') //写成一行 }--> </script></body></html>新建文件lyhshow2.html输入<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title></title></head><body>请输入:<input type="text" id="txtValue" value=""><br><br><br><input type="button" onclick="ReturnValue()" value="返回输入值"><script language="javascript">function ReturnValue(){window.opener.document.all.returnvalue.value=document.all.txtValue.value;window.close();}</script></body></html> 手写的,还是热的!tt.html:<html><head></head><body><script>function test(){ window.open('pp.html');}</script><input type='text' id='tt_t'><input type='button' value='button' onclick='test()'></body></html>------------------------------------------------------------------pp.html:<html><head></head><script> function c() { window.opener.document.getElementById('tt_t').value=document.getElementById('pp_t').value; window.close(); }</script><body><input id='pp_t' type='text'><input type='button' value='button' onclick='c()'></body></html> 在MSDN中找跨页面传值,都是你要的东西。PriviousPage.... 在ASP.NET高级编程2.0 (Wrox)也讲到这方面的内容。 在前台查出你选中行的第六列的值。 function ADD() { var index = <%=this.GridItems.SelectedIndex%>;//取子窗体控件选中的索引 var text = document.getElementById("GridItems").rows[index + 1].cells[1].innerText; window.opener.document.form1.txtCoRe.value = text; window.close(); } 这是我以前做开发的时候写的一个单击父窗体BUTTON弹出子窗体,取子窗体Gridview我选择的那一行的第一列的值,点确定然后关闭子窗体,然后返回给父窗体的txtCoRe文本框. 非常感谢大家,可是这些方法在.aspx中不能用啊!我还是没有做出来! 可是这些方法在.aspx中不能用啊! ???=====================================俺就比较纳闷?还请lz说说怎么个不能用法? 上面大多都是JS语言,在aspx中不能用?LZ说说怎么不能用啊 非常感谢大家,可是这些方法在.aspx中不能用啊!我还是没有做出来!?????------------------------------------js语言怎么可能在aspx中不能用呢,建义你还是多多去看js语言吧 <html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>父页面</title><script language="javascript" type="text/javascript">// <!CDATA[function bt_set_onclick() {window.open("bb.aspx");}// ]]></script></head><body style="text-align: center"> <form id="form1" runat="server"> <div> <input id="aa" name="name" type="text" /><br /> <br /> <input id="bt_set" type="button" value="button" onclick="return bt_set_onclick()" /> </div> </form></body></html>上面的是页面aa.aspx的代码下面是bb.aspx的代码:<html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>子页面</title><script language="javascript" type="text/javascript">// <!CDATA[function bt_up_onclick() {window.opener.document.form1.getElementById('aa').value=document.getElementById('bb').value;}// ]]></script></head><body style="text-align: center"> <form id="form1" runat="server"> <div> <br /> <br /> <input id="bb" name="depart" type="text" /> <input id="bt_up" type="button" value="button" onclick="return bt_up_onclick()" /></div> </form></body></html>高手帮我看一下我写的对不对?? 哦,我没有写window.close();为何就错了呢?我现在加上了上面的话然后就对了!谢谢各位,我是要多看看JS语言!! 为什么在bb.aspx中用到提交的控件时就出错,而用到html中的提交按钮就对呢?? 用session完全可以解决!为什么2次用a.aspx就不能用Session?我没想明白,你只不过是1次取值的过程而已 session如果可以的话我就用了,可是里面存在一个先后的问题。不是session的问题! 为什么在bb.aspx中用到提交的控件时就出错,而用到html中的提交按钮就对呢??------------------------------------------------------------------------------有这种事?怪异! 是的啊,我也没有想通,后来我就用的html中的提交按钮,一用控件就提示:没有符合的操作! 支付宝问题?打钱和提现 asp.net 自带的cache可以在负载均衡后缓存共享吗,就像memcached那样? VS2005编辑ASPX页面问题,不能显示下面内容? 如何去掉FCKEditor编辑框内自动给网址加链接的功能? 请问这种导航应该怎么做? 这段JSP为什么显示为乱码 急:自定义控件(ascx)提交数据时,怎么能让父页面(aspx)数据重新邦定一次? 各位有能之士:怎么实现判定一个用户在线与不在线呀?还有在线人数的统计?(论坛) 高手,救济、、 100分。。在线等。。。 C/S WCF 服务方法调用问题 一条赋值诗句的问题! 上传图片抛出异常(内存不足)
在子窗口b.aspx中opener
方法一:使用showModalDialog方法新建文件lyh.html
输入 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
</head><body>
<input type="button" onclick="show('lyhshow.html')" value="弹出窗口"><br><br><br>返回值:
<input type="text" id="returnvalue"><script language="javascript">
function show(math)
{
var val= showModalDialog(math,"true", "dialogWidth:300px;dialogHeight:250px;status:no;help:no;");
if(!val)
{
return;
}
else
{
document.all.returnvalue.value=val;
}
}
</script>
</body>
</html>
新建文件lyhshow.html
输入
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>来自Eric空间</title>
</head><body>
请输入:<input type="text" id="txtValue" value=""><br><br><br>
<input type="button" onclick="ReturnValue()" value="返回输入值"><script language="javascript">
function ReturnValue()
{
window.returnValue=document.all.txtValue.value;
window.close();
}
</script>
</body>
</html>方法二:用window.open弹出窗口新建文件lyh2.html
输入
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>来自Eric空间</title>
</head><body>
<input type="button" onclick="show('lyhshow2.html')" value="弹出窗口"><br><br><br>返回值:
<input type="text" id="returnvalue"><script language="javascript">
<!--
function show(math)
{window.open (math,'newwindow','height=250,width=300,top=300,left=300,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no')
//写成一行 }
-->
</script>
</body>
</html>
新建文件lyhshow2.html
输入<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
</head><body>
请输入:<input type="text" id="txtValue" value=""><br><br><br>
<input type="button" onclick="ReturnValue()" value="返回输入值"><script language="javascript">
function ReturnValue()
{
window.opener.document.all.returnvalue.value=document.all.txtValue.value;
window.close();
}
</script>
</body>
</html>
tt.html:
<html>
<head></head>
<body>
<script>
function test()
{
window.open('pp.html');
}
</script>
<input type='text' id='tt_t'>
<input type='button' value='button' onclick='test()'>
</body>
</html>
------------------------------------------------------------------
pp.html:
<html>
<head></head>
<script>
function c()
{
window.opener.document.getElementById('tt_t').value=document.getElementById('pp_t').value;
window.close();
}
</script>
<body>
<input id='pp_t' type='text'><input type='button' value='button' onclick='c()'>
</body>
</html>
function ADD()
{
var index = <%=this.GridItems.SelectedIndex%>;//取子窗体控件选中的索引
var text = document.getElementById("GridItems").rows[index + 1].cells[1].innerText;
window.opener.document.form1.txtCoRe.value = text;
window.close();
} 这是我以前做开发的时候写的一个单击父窗体BUTTON弹出子窗体,取子窗体Gridview我选择的那一行的第一列的值,点确定然后关闭子窗体,然后返回给父窗体的txtCoRe文本框.
=====================================
俺就比较纳闷?还请lz说说怎么个不能用法?
LZ说说怎么不能用啊
------------------------------------
js语言怎么可能在aspx中不能用呢,建义你还是多多去看js语言吧
<head runat="server">
<title>父页面</title>
<script language="javascript" type="text/javascript">
// <!CDATA[function bt_set_onclick() {
window.open("bb.aspx");
}// ]]>
</script>
</head>
<body style="text-align: center">
<form id="form1" runat="server">
<div>
<input id="aa" name="name" type="text" /><br />
<br />
<input id="bt_set" type="button" value="button" onclick="return bt_set_onclick()" /> </div>
</form>
</body>
</html>
上面的是页面aa.aspx的代码
下面是bb.aspx的代码:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>子页面</title>
<script language="javascript" type="text/javascript">
// <!CDATA[function bt_up_onclick() {
window.opener.document.form1.getElementById('aa').value=document.getElementById('bb').value;}// ]]>
</script>
</head>
<body style="text-align: center">
<form id="form1" runat="server">
<div>
<br />
<br />
<input id="bb" name="depart" type="text" />
<input id="bt_up" type="button" value="button" onclick="return bt_up_onclick()" /></div>
</form>
</body>
</html>
高手帮我看一下我写的对不对??
我现在加上了上面的话然后就对了!
谢谢各位,我是要多看看JS语言!!
------------------------------------------------------------------------------
有这种事?怪异!