javascript in popup calling some function in main web form

G

geoff

I've got an add form with a link that opens a pop up window. The main
add form has a drop down menu with items populated from a db. In the
popup window, you can add additional items to the db, so when you do,
what I'd like to do is somehow refresh the main screen to show the
updates, but at the same time, keeping any data in the page that the
user has already entered. Has anyone found a solution for these types
of situations? Thanks.
 
T

Teemu Keiski

Hi,

if the main page has JavaScript method "methodname" declared, you can always
call it from the popup by using:

window.opener.methodname(<possible arguments>);

This method could cause a postback or reload or whatever at the main page.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke


I've got an add form with a link that opens a pop up window. The main
add form has a drop down menu with items populated from a db. In the
popup window, you can add additional items to the db, so when you do,
what I'd like to do is somehow refresh the main screen to show the
updates, but at the same time, keeping any data in the page that the
user has already entered. Has anyone found a solution for these types
of situations? Thanks.
 
G

geoff tyler

Sorry, guess I should have clarified. I realize that I can call a
javascript function that way in the main page... my biggest hurdle is
how can I get javascript to do a postback?
 
G

Guest

Try add the code like following in the function in the main page

window.form1.submit()

Bin Song, MC

----- geoff tyler wrote: ----

Sorry, guess I should have clarified. I realize that I can call
javascript function that way in the main page... my biggest hurdle i
how can I get javascript to do a postback

*** Sent via Developersdex http://www.developersdex.com **
Don't just participate in USENET...get rewarded for it
 
T

Teemu Keiski

You can try calling submit() for the form, but you could also try to post in
behalf of another control say a button on form, if taht's suitable. You can
generate the script for this by using Page.GetPostBackEventReference, and
this returned js snippet you place inside the function which you call from
popup window.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke


Sorry, guess I should have clarified. I realize that I can call a
javascript function that way in the main page... my biggest hurdle is
how can I get javascript to do a postback?
 
G

geoff tyler

Teemu, thanks - that worked perfectly. I already had a refresh link set
up to refresh the source, so I just called the javascript that is called
when you click that link and it worked great. Thanks a lot!
 

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
473,781
Messages
2,569,615
Members
45,296
Latest member
HeikeHolli

Latest Threads

Top