Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Force Post Back from Client Side - Modal Window

Posted on 2004-08-16
5
Medium Priority
?
588 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 8

Accepted Solution

by:
shovavnik earned 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

971 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