We help IT Professionals succeed at work.

passing an imageurl using window.opener.document.getElementById

attipa
attipa asked
on
i have two pages:

page-a.aspx
<asp:Image ID="Image1" runat="server />
<a href="#" onclick="window.open('pg-addimage.aspx?Image=Image1', 'addimagewindow', 'width=600px,height=450px,left=250px,top=150px,scrollbars=yes');return false;" class="admin-field-links">Add</a>

pg-addimage.aspx.vb
'when button is clicked
Response.Write("<script>window.opener.document.getElementById('ImageURL"').value =  & r("PGImageURL").ToString() & ";</script>")
Response.Write("<script>window.close();</script>")

how can i pass a value through to load an image on the parent page.  .imageurl and .value is not woring.
Comment
Watch Question

Hi,

Try "src".

To set the image for asp:Image from javascript you should use "src" attribute. NOT imageurl or value.

Author

Commented:
src didn't work.
Do you have Master Page for that opener page?

Author

Commented:
yes

Author

Commented:
look at code above that says page-a.aspx
If you have master page, the id of the control will not be same as which you gave. In run time the id of the control will be changed. In prefix it will add contentplaceholder's id.

For example if you have image id as Image1, in run time it will be changed something like ctl00_ContentPlaceHolder1_Image1. To find the id of your control in run time right click your page at run time and go to view source.

You have to use the id which is displayed in view source.

Here is the solved thread with the same problem.
http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_24945521.html

Author

Commented:
The image Id remains image1 in view source. I am not dynamically creating the image, it's hard coded so the id will not change.  

Author

Commented:
sorry...my mistake....i have to put '        '   around the actualy souce.