Suppose that I have an ASP.NET page that is intended for other sites to render inside of their <iframe>
. Suppose further that my page includes some server-side <asp:LinkButton>
controls, which get rendered as <a href="javascript:__doPostBack(...)">
links.
I would be happy if _doPostBack() would execute within the iframe, but it does not--Instead I get "_doPostBack not defined" error in the console. I presume that is because it is trying to execute it on the outside page, because it is an href="javascript:..." link and not an ordinary DOM event.
How can I overcome this without changing away from a LinkButton? Is there a better way to run the server-side code I need for clicking the button?
EDIT: I added an the <a href="javascript:alert(document.title)">test</a>
and clicked on it, and I got the title of my outer page, not the title of my page in the iframe.
I might not be getting the question right...but the link button in your iframe should work fine only inside the iframe context. So anything in the code-behind of the iframe .aspx will work as regular.
Now if you want the link_button in iframe to interact with the parent page the nope. What you are trying to do is a Cross-domain scenario. I doubt there's any way you might be able to accomplish it and that's due to security reasons. I was looking for something like that as asked here.
If you own both the websites then you might want to check if WebService is of any use.