Solved

Force Post Back from Client Side - Modal Window

Posted on 2004-08-16
5
576 Views
Last Modified: 2008-01-09
I need to be able to force a post back from the client side using Java Script.  I ONLY support internet explorer and use Visual Studio .Net with V1.1 of the architecture.

Thanks,

Bill
0
Comment
Question by:billy21
  • 3
5 Comments
 
LVL 6

Author Comment

by:billy21
ID: 11807701
Oh and don't forget this is a MODAL dialog window.  I understand this complicates things.  I want the simplest possible solution.

cheers,

Bill.
0
 

Expert Comment

by:amt777
ID: 11807716
first you need to have on your page any object with runat=server and autoPostBack is true.
you can hide this object (ext. button).
write the vb script lke this:
execScript      "javascript:__doPostBack('$button','')"


amit
0
 
LVL 6

Author Comment

by:billy21
ID: 11807736
I've been told __doPostBack doesn't work on a modal form.  I certainly couldn't get it to work.
0
 
LVL 6

Author Comment

by:billy21
ID: 11807749
0
 
LVL 8

Accepted Solution

by:
shovavnik earned 500 total points
ID: 11808582
I'll repost my answer here, as I'm pretty sure it's what you're looking for, and this question is more specific.  I also fixed it up a bit.

You can't post back in modal dialog windows directly.  The only way (as far as I know) to do so is to use an iframe (or maybe just a regular frameset, though I've never tried a frameset).

Try the following.  You'll need to make three different files.  Keep in mind, this is off the top of my head, so I may have a property name wrong here or there.

In the main browser window, you have something like:

var dlgResult = window.showModalDialog( 'DialogContainer.aspx', features );

Then in DialogContainer.aspx:

<html>
<head>
<script>
function closeDialog( result ) {
  window.dialogResult = result;
  window.close();
}
</script>
<body>
<iframe framewidth="100%" frameheight="100%" src="PostBackPage.aspx"></iframe>
<form runat="server" id="DialogContainer" style="display:none;"></id>
</body>
</html>

Then PostBackPage.aspx is the actual page that needs to be able to post back to itself.

When you want to return the results of your iframe to the main page from PostBackPage.aspx, you call:
top.closeDialog( 'MyResult' );


That's it.  You hardly have to make any changes to your existing code.  All you need to do is open the dialog window with a container page that has an iframe whose source is your problematic page.  Just add a middle-man.

The problem is that a modal dialog is not a real browser window in IE (I can't recall if Mozilla type browsers and others work the same way though).
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Class Library Dynamics For Connectstring Information 2 21
getting id from database 5 37
Asp.net mvc foreach 3 34
Error in page 3 45
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Edureka is one of the fastest growing and most effective online learning sites.  We are here to help you succeed.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now