Friday 16 September 2011

Access and set properties for controls on main page inside an iframe page using vb.net 1.*?

Hi



I have a asp.net page (index.aspx) which has an inframe in which I opened another page (questions.aspx). If a button on the questions page is clicked, I want to change the url of a server image control that is on the main page. How do I do this and how do I in general, access and set properties of main form controls from a page in the in-frame?



Thanking you in advance.



ZabronAccess and set properties for controls on main page inside an iframe page using vb.net 1.*?If you want to use .NET functionality, you'll need to either redraw the entire main page, including the iframe or seriously hack the client side controls. If you are using a tamper-proof viewstate, the hacking option isn't possible. I wouldn't recommend that anyway, as an update to the .NET runtime might invalidate your hack.



If you don't mind doing this on the client and not affecting the server side view of the controls, you can use CSS and javascript to locate the main frame (the %26quot;top%26quot; object) and change the image, for example:



top.myImage.src = %26quot;whatever.jpg%26quot;;



Another option is to write a custom control in place of the iframe. This option is pretty complicated and you should look in the documentation for writing a custom control to learn how to do basic custom controls. A last option would be to use an included page instead of an iframe, this would put all the contorls on the same level (i.e. no iframe) which makes it easier for .NET controls to communicate with each other on th client side and still stay synchronized with the server side.