IFrame\HiddenFleld

G

gh

I have an asp.net page that is being displayed in an IFrame of a html
page. The html site is on a different server than the asp.net page. I
have a value I would like to pass to the html page. Can I store the
value in a hidden field of the asp.net page and access it from the html
page, using js? If not can I pass the value in the url? I am using VS 2008

TIA
 
S

siccolo

I have an asp.net page that is being displayed in an IFrame of a html
page.  The html site is on a different server than the asp.net page.  I
have a value I would like to pass to the html page.  Can I store the
value in a hidden field of the asp.net page and access it from the html
page, using js?  If not can I pass the value in the url?  I am using VS 2008

TIA

for example, if you have a button in iFrame aspx page:

<input type="button" onclick="pass_value_to_html();" />

and in your iFrame aspx page:
<script>
function pass_value_to_html()
{
var value_to_pass = "test_value_from_iframe";
window.parent.set_value_from_iframe(value_to_pass);
}
</script>

and in your html page:
<iframe src="asp_page.aspx" />
<script>
function set_value_from_iframe(value_from_iframe)
{
alert( "got value:" + value_from_iframe);
}
</script>


... more at http://www.siccolo.com/articles.asp
 
M

Munna

Hi

lets say the bellow markup is your inner aspx page...

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="text" id="txtInput" />
<h2 id="yahoo">Inner frame</h2>
</div>
<script>
// window.alert(document.getElementById("yahoo"));
</script>
</form>
</body>
</html>

and This is the page that hold the iframe

<head runat="server">
<title>Untitled Page</title>

</head>
<body onload="afunction()">
<form id="form1" runat="server">
<div>
<iframe id="someframe" src="WebForm1.aspx"></iframe>
</div>
</form>

</body>
<script language="javascript" type="text/javascript">
function afunction()
{
var frame = document.getElementById('someframe'); //this is
your frame
var innerdocument = frame.contentWindow.document; //this is
your frame's inner document
window.alert(innerdocument.getElementById("yahoo"));
}
</script>
</html>

Best of luck

Munna

www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com
 
P

Peter Bucher [MVP]

Hello TIA
I have an asp.net page that is being displayed in an IFrame of a html page.
The html site is on a different server than the asp.net page. I have a
value I would like to pass to the html page. Can I store the value in a
hidden field of the asp.net page and access it from the html page, using
js? If not can I pass the value in the url? I am using VS 2008
NO

except you mark _both_ sites with a little javascript, like:

document.domain = '<domain>';

Look at:
- http://www.google.ch/search?hl=de&q=document.domain&meta=
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top