DoPostBack from Popup (Child) Window

N

Nathan Burleson

Hello,

I have a custom control that is used to select a location from a list
of locations. When put on the page it creates an asp:textbox (used to
display the name of the location), a hidden field (which stores the
primary key of the location from the DB) and an image button. When you
click the image button a popup is created that allows you to select an
item from a complex screen (tabbed interface, etc).

The important thing is that when you have selected the location you
wish and click on the "Select" button in the popup it tries to call
_doPostBack on the Parent Window and then close itself. This works
fine as long as you have some form elements on the page the "force"
asp.net to put the __doPostBack function on the page. But, if you
don't have these items then __doPostBack is not created on the page,
and the child window fails by trying to call a parent method that
doesn't exist.

I need a way to force the "parent" page to create the __doPostBack
method whether it thinks it needs it or not.

I looked into GetPostBackClientEvent, but I don't think I can use it
since I am in a child window.

Any suggestions?

Thanks.
--Nathan
 
A

Ather Ali Shaikh

I am using RegisterClientScriptBlock
and in it I use window.opener.document.forms[0].submit();
this will allow the parent window to post back.
 
N

Nathan Burleson

Hello Ather,

Thanks for the quick response. However, in my case I can not just
submit the form as there may be Validators on the "parent" page. I did
find a solution for your future reference.

I perform the following call inside the container page which houses
the child control:

Page.GetPostBackClientEvent(LC1, "")

LC1 refers to the child control. This forces asp.net to put the
__doPostBack client javascript onto the page.

Thanks again for your help.
--Nathan

Ather Ali Shaikh said:
I am using RegisterClientScriptBlock
and in it I use window.opener.document.forms[0].submit();
this will allow the parent window to post back.


Nathan Burleson said:
Hello,

I have a custom control that is used to select a location from a list
of locations. When put on the page it creates an asp:textbox (used to
display the name of the location), a hidden field (which stores the
primary key of the location from the DB) and an image button. When you
click the image button a popup is created that allows you to select an
item from a complex screen (tabbed interface, etc).

The important thing is that when you have selected the location you
wish and click on the "Select" button in the popup it tries to call
_doPostBack on the Parent Window and then close itself. This works
fine as long as you have some form elements on the page the "force"
asp.net to put the __doPostBack function on the page. But, if you
don't have these items then __doPostBack is not created on the page,
and the child window fails by trying to call a parent method that
doesn't exist.

I need a way to force the "parent" page to create the __doPostBack
method whether it thinks it needs it or not.

I looked into GetPostBackClientEvent, but I don't think I can use it
since I am in a child window.

Any suggestions?

Thanks.
--Nathan
 

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

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top