.net中如何让iframe的src获得页面中textbox的值啊
2个回答
展开全部
其实这部分控制和标准Html是一样的,使用
parent.对象.document.表单名.textbox控件名.value
如下程序应该会对您有帮助!
=============================
index.htm
---------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<style type="text/css">
</style>
<script language="javascript">
function ShowIFMess()
{
alert(parent.test.document.form1.txtMess.value);
}
</script>
</head>
<body onLoad="ShowIFMess()" bgcolor="#FFFFFF" leftmargin="0" topmargin="0">
<iframe id="test" name="test" src="i.htm"></iframe>
</body>
</html>
================
i.htm
-----
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<style type="text/css">
</style>
<script language="javascript">
</script>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0">
<form name="form1" method="post" action="">
<input name="txtMess" type="text" value="This is IFrame Context">
<input type="submit" name="Submit" value="提交">
</form>
</body>
</html>
==============
还有若您所的是传值,那您也可以通过Session来实现,这部分是ASP.NET封装的
parent.对象.document.表单名.textbox控件名.value
如下程序应该会对您有帮助!
=============================
index.htm
---------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<style type="text/css">
</style>
<script language="javascript">
function ShowIFMess()
{
alert(parent.test.document.form1.txtMess.value);
}
</script>
</head>
<body onLoad="ShowIFMess()" bgcolor="#FFFFFF" leftmargin="0" topmargin="0">
<iframe id="test" name="test" src="i.htm"></iframe>
</body>
</html>
================
i.htm
-----
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<style type="text/css">
</style>
<script language="javascript">
</script>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0">
<form name="form1" method="post" action="">
<input name="txtMess" type="text" value="This is IFrame Context">
<input type="submit" name="Submit" value="提交">
</form>
</body>
</html>
==============
还有若您所的是传值,那您也可以通过Session来实现,这部分是ASP.NET封装的
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询