Using Javascript to force Postback on opening page

Page 1 opens a modal dialog, Page 2, using showModalDialog.  When Page 2 closes it passes some data back to Page 1 and then closes.  (code below).  How can I get Page 2 (modal dialog) to make Page 1 (the opening page) do a postback?

Here's the code from Page 2:
Dim sScript As String
            sScript = "<script language=javascript> "
            'sScript += " dialogArguments.location.href = 'memAddAddress.aspx'; "
            sScript += " var pwid = window.dialogArguments.document.all;"
            sScript += " pwid('ucCompany:txtCompany').value='" + txtCompany + "';"
            sScript += " window.close();"
            sScript += "</script>"
            Page.RegisterStartupScript("ClosePage", sScript)
thespicemanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tusharashahCommented:
Add following line before you close popup in your code and see:

  sScript += "window.opener.location = YourParentPage.aspx;";

-tushar
0
tusharashahCommented:
CORRECTION:

 sScript += "window.opener.location = 'YourParentPage.aspx';"

Those little ' ' are required

-tushar
0
thespicemanAuthor Commented:
I get the following errer:  'window.opener' is null or not an object
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

thespicemanAuthor Commented:
I get the following error:  'window.opener' is null or not an object.  This is because I did not open the window using window.open but instead use window.showModalDialog.
0
tusharashahCommented:
How exactly are you opening your 2nd page?
0
thespicemanAuthor Commented:
Here's how...
Dim sCommand As String = "<script language=javascript>window.showModalDialog('Validation.aspx',window,'dialogHeight:600px;dialogWidth:630px;scrollbars:no;help:no;status:no');</script>"
 Page.RegisterStartupScript("memAddressValidation", sCommand)
0
thespicemanAuthor Commented:
tusharashah,
This causes a refresh of the page but not a postback.
 sScript += " dialogArguments.location.href = 'memAddAddress.aspx';"
0
tusharashahCommented:
Try to use following line:

sScript += "window.dialogArguments.location.reload(true);"

-tushar
0
thespicemanAuthor Commented:
It kind of works.  It does cause the page to postback...BUT...
first I get the error:  The page cannot be refreshed without resending the information.  Click retry to send the information again...

I click Retry and the page does do a postback but the new values that I have loaded in the textboxes ( sScript += " pwid('ucCompany:txtCompany').value='" + txtCompany + "';") are not present
0
tusharashahCommented:
You must be posting or saving some hidden fields on your Parent page. Is it possible to avoid that? & if not then how about passing txtCompany as QueryString and refresthing the page?

 sScript += " dialogArguments.location.href = 'memAddAddress.aspx?Company" + txtCompany + "';"

-tushar
0
thespicemanAuthor Commented:
That won't work for me.  This page can be called from many different places (via a user control) so it has to be as generic as possible.  I do have it working by doing:  
 sScript += " pwid('btnAdd').click();"

This will work but I will have to change 6+ calling pages.  I would like to find a more 'generic' solution.
0
thespicemanAuthor Commented:
I've figured out a solution.  I am forcing a postback by the the following:

sScript += " var pwid = window.dialogArguments.document.all;"
sScript += " pwid('" + Session("AddressSubmitName") + "').click();"
0
moduloCommented:
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.