How can I Postback a page inside a iframe from the container page?

Hi

How can I invoke the postback of a page inside a iframe from its container page?

I've got a iframe inside a .aspx page (main), the iframe loads another .aspx page, the user can do several things in this iframe page like capture data. Now, I want, from a button on the main page, to make the iframe aspx postback.

How can I do that.
Thanks
mak730Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

weareuProgrammerCommented:
<a href="javascript:document.getElementById('myIFrame').contentWindow.execScript('__doPostBack('ActionPostback','');');">postback my little iframe</a>
<iframe id="myIFrame" src="mypage.aspx">
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
weareuProgrammerCommented:
make sure your page mypage registers it's postback script:
do this by putting

this.Page.GetPostBackEventReference(this);

in the override protected void OnInit(EventArgs e) (this is generated by VS.NET for aspx pages in the "Web Form Designer generated code" region)
0
nauman_ahmedCommented:
Check out the following article:

Title: DotNetJunkies :: On-the-Fly Non-Postback .NET Server Validation
URL: http://www.dotnetjunkies.com/Article/E02F3646-CB1C-4252-8AEC-5F485E90A231.dcik

HTH, Nauman.
0
mak730Author Commented:
weareu, your code works simply right!

Thanks a lot

A couple of questions more:
1)contentWindow.execScript() works on Netscape, Opera and Firefox also, or just IE?
2)How, on serverside, do I receive the value of the param: 'ActionPostback' of the __doPostBack('ActionPostback', '')?

Points are yours
0
weareuProgrammerCommented:
Yes contentWindow.execScript works on mozilla (dunno about opera or firefox)

You cannot receive the value in normal ASPX page without alot of hard work... if you need to postback additional values, create a hidden input (that runs server side) runat="server" and before you do the postback script set the value of this hidden input to also postback... remember that the hidden input has to be inside the iframe page for you to retrieve it server-side there. Also remember since it is in the iframe page you need to access it in the same kind of way to set the value so before __doPostBack(... do

document.getElementById('myIFrame').contentWindow.execScript('document.getElementById(\'hiddenPBvalue\').value = \'postback something\';');

and then document.getElementById('myIFrame').contentWindow.execScript('__doPostBack('ActionPostback','');');

when your page posts back the serverside hidden input will contain the value 'postback something'...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.