Solved

Force Post Back from Client Side - Modal Window

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
convert html to string 6 34
Delete HTML table rows 12 27
Need to start a web service from Visual Studio 2015 Pro 2 21
ASP.NET MVC -Add authentication 2 19
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

815 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

13 Experts available now in Live!

Get 1:1 Help Now