Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > IFrame\HiddenFleld

Reply
Thread Tools

IFrame\HiddenFleld

 
 
gh
Guest
Posts: n/a
 
      06-09-2008
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
 
Reply With Quote
 
 
 
 
siccolo
Guest
Posts: n/a
 
      06-09-2008
On Jun 9, 10:28*am, gh <(E-Mail Removed)> wrote:
> 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
 
Reply With Quote
 
 
 
 
Munna
Guest
Posts: n/a
 
      06-09-2008
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
 
Reply With Quote
 
Peter Bucher [MVP]
Guest
Posts: n/a
 
      06-11-2008
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=...t.domain&meta=

--
Gruss, Peter Bucher
Microsoft MVP - Visual Developer ASP / ASP.NET, Switzerland
http://www.aspnetzone.de/ - ASP.NET Zone, die ASP.NET Community
http://www.aspnetzone.de/blogs/peterbucher/ - Auf den Spuren von .NET

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments