日期:2014-05-18  浏览次数:20446 次

关于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的值。这应当如何来实现呢?高手帮忙啊!!!!!

------解决方案--------------------
网上转的
方法一:使用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>
<inp