读书人

关于Asp.net页面间传递参数的有关问题

发布时间: 2013-07-08 14:13:00 作者: rapoo

【求助】关于Asp.net页面间传递参数的问题
本帖最后由 liuyunzhi82 于 2013-06-26 17:48:53 编辑 我有一个纯html页面index.htm在里面嵌套了一个ifram


<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<iframe src="http://localhost:2690/UserLoginForCms.aspx" width="230" frameborder="0" scrolling="no">
</iframe>
</td>
</tr>
</table>

在index.htm页面中的body中的onload事件加入了
<body style="margin: 0 auto;" onload="displayScreenSize()">

javascript的代码如下

<head>
<script language="javascript">
function displayScreenSize() {
document.getElementById("sWidth").value = document.documentElement.clientWidth;
document.getElementById("sHeight").value = document.documentElement.clientHeight;
}
</script>
</head>

现在我想做的是将“sWidth”和“sHeight”这两个Hidden的值传给UserLoginForCms.aspx页面,现在我能想到的方法是这样的

<iframe src="http://localhost:2690/UserLoginForCms.aspx?swidth=sWidth的value值&sHieght=sHeight的value值" width="230" frameborder="0" scrolling="no">

请问我应该怎么做才能取到那两个控件的value值,并把它们作为问号后面的变量参数呢?
如果还有什么其他简单的方法也请指教一二,屏幕的宽度与高度值我只能在这个母页面取才正常,所以这两个值只能从这个页面传出去。


[解决办法]


<iframe src="#" style="text-align: left" name="mainFrame" id="mainFrame"
width="100%" height="100%" frameborder="0" scrolling="auto" onload="initFrame();">
</iframe>


var url=...//拼接
$('#mainFrame').attr('src', url);

[解决办法]
引用:
我有一个纯html页面index.htm在里面嵌套了一个ifram

<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<iframe src="http://localhost:2690/UserLoginForCms.aspx" width="230" frameborder="0" scrolling="no">
</iframe>
</td>
</tr>
</table>

在index.htm页面中的body中的onload事件加入了
<body style="margin: 0 auto;" onload="displayScreenSize()">

javascript的代码如下

<head>
<script language="javascript">
function displayScreenSize() {
document.getElementById("sWidth").value = document.documentElement.clientWidth;
document.getElementById("sHeight").value = document.documentElement.clientHeight;
}
</script>


</head>


现在我想做的是将“sWidth”和“sHeight”这两个Hidden的值传给UserLoginForCms.aspx页面,现在我能想到的方法是这样的

<iframe src="http://localhost:2690/UserLoginForCms.aspx?swidth=sWidth的value值&sHieght=sHeight的value值" width="230" frameborder="0" scrolling="no">

请问我应该怎么做才能取到那两个控件的value值,并把它们作为问号后面的变量参数呢?
如果还有什么其他简单的方法也请指教一二,屏幕的宽度与高度值我只能在这个母页面取才正常,所以这两个值只能从这个页面传出去。

把ifame加上一个id 如:id="ifam":
然后在页面的尾部 加上一个javascript代码:
<script type="text/javascript">
var w=document.getElementById("sWidth").value;
var h=document.getElementById("sHidth").value;
document.getElementById("ifam").src = "http://localhost:2690/UserLoginForCms.aspx?swidth=w&sHieght=h";
</script>

[解决办法]
给<iframe src="http://localhost:2690/UserLoginForCms.aspx" width="230" frameborder="0" scrolling="no"> </iframe>
加个ID,然后在你加载的时候,
直接displayScreenSize(){}将这里面的代码变为下面的代码看看。
function displayScreenSize()
{
var swidth= document.documentElement.clientWidth;
var sHeight= document.documentElement.clientHeight;
document.getElementById("ID").src="http://localhost:2690/UserLoginForCms.aspx?swidth=sWidth&sHieght=sHeight";
}

读书人网 >asp.net

热点推荐