Update field in parent window that is a user control

  • Thread starter Thread starter Guest
  • Start date Start date
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??
 
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
 
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.
 
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.
 
Back
Top