Update field in parent window that is a user control

G

Guest

Got my main form test.aspx
This opens a new window with window.open
everything works.

I now want to update the parent window with the following code
window.opener.document.forms[0].lblSalesman.value = "Joe Bloggs";

Seems to work fine when the opening page is a control in an aspx page
but when I have a user control on that aspx page it doesn't seem to update
the control. the control is an asp:textbox control.

Any ideas??
 
D

Dave Fancher

Take a look at the source of the generated page after it has been rendered
to see exactly what is being used for the name of the control. Controls
inside of UserControls have text prepended to make them uniquely
identifiable with the ViewState.

HTH
 
J

Jeffrey Tan[MSFT]

Hi yogib,

Thanks for your post!!

Yes, just as Dave pointed out, because UserControl implemented
INamingContainer interface, the control in the usercontrol may render in a
different id html attribute, instead of the default "lblSalesman". We can
use "View Source" command to view the html result of the aspx page, then we
can determine the "real" rendered id attribute of that control.
Also, with asp.net, we can determine the result rendered id
programmatically with Control.ClientID property.

With the correct id, we can get the reference to the control in javascript
like below:
window.opener.document.getElementById("correct id").value = "Joe Bloggs";

Hope this helps
============================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jeffrey Tan[MSFT]

Hi yogib,

Does our replies make sense to you? Is your problem resolved? If you still
need help, please feel free to feedback, thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top