Click here to Skip to main content
15,895,799 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Hai,
I want to set a values to my parent page Label without reloading parentpage. I need to post values from iframe page to parent page.
provide any javascript or c# samples.
Thanks in advance.
Posted

1 solution

The parent window is accessible via the parent window object, thus you can use the following javascript:
C#
parent.document.getElementById('parentLabel').innerHTML='some other text!';


For a practicle example create the following two pages...
parent.htm:
XML
<html>
<head>
    <title>Parent Page</title>
</head>
<body>
<div id="parentLabel">this is some text.</div>
<iframe src="child.htm"></iframe>
</body>
</html>

and child.htm:
XML
<html>
<head>
    <title>Child Page</title>
</head>
</head>
<body>
<a href="#" onclick="javascript:parent.document.getElementById('parentLabel').innerHTML='some other text!';return false;">update label</a>
</body>
</html>

Then open parent.htm in your fav browser and click on the link in the framed page.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900