0

I don't know if this is even possible, but here goes: I have an ASP.NET page that contains an IFrame that calls an HTML page. Is it possible to pass a variable from the ASP.NET page to the HTML within the IFrame? More specifically, I'd like for the ASP.NET page to fill in one of the fields on the form within the HTML page.

3
  • Can the form field be filled in by a query string value? If not, you may be out of luck. Commented Aug 23, 2010 at 17:31
  • Remember that the iframe has to be on the same domain (subdomain) in order for cross frame communications to work. Commented Aug 23, 2010 at 17:39
  • No, it must be in the form. Its for a PP form and the whole this is sent as a post request Commented Aug 23, 2010 at 17:46

2 Answers 2

1

You could do something like this:

window.frames['IFrameName'].document.getElementById('TextBoxID').value='YourValue';
Sign up to request clarification or add additional context in comments.

2 Comments

I'm assuming this is javascript?
Yes, sorry. Basically, it's javascript to find the textbox element in the IFrame and set it's value. You may need to add some logic to make sure the IFrame's page is loaded, but other than that, this should work.
0

If you only need it to work with the latest browsers then window.postMessage is the way to go to communicate between frames.

See: http://msdn.microsoft.com/en-us/library/cc197015

1 Comment

Nice suggetion but I'm not ready to make the move to HTML 5 yet

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.