js是很强大的,就是因为它的强大至今我都没搞定它。。。
最近小接触了下,用到了页面间的传值,不得不写下,主要怕以后忘了。。。呵呵。。。
页面1:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
function LoadSysOption()
{
var URL="/js44.aspx?";//跳到页面2
var popstyle = "DialogWidth:500px; DialogHeight=400px; status:no";
var obj=new Object();
obj.txt=document.getElementById('txtPriv');
window.showModalDialog(URL,obj,popstyle);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtPriv" runat="server"></asp:TextBox>
<input id="Button1" type="button" value="button" onclick="LoadSysOption()"/></div>
</form>
</body>
</html>
页面2:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
function add()
{
var text=document.getElementById('TextBox1').value;
var obj=parent.dialogArguments;//这个很关键
obj.txt.value=text;//把TextBox1的值传给页面1中的TextBox
window.close();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<input id="Button1" type="button" value="button" onclick="add()"/></div>
</form>
</body>
</html>
其实对于这个简单的js原理我也不是很清楚的。。。