Solved

Force Post Back from Client Side - Modal Window

Posted on 2004-08-16
5
575 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

746 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

10 Experts available now in Live!

Get 1:1 Help Now