Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Force Post Back from Client Side - Modal Window

Posted on 2004-08-16
5
Medium Priority
?
584 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

721 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