473,418 Members | 2,121 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

Initiating a PostBack on a main window from a popup window

Jay
I have a situation where the user clicks on a button in a
DataGrid to launch a popup window via javascript. In the
popup window the user does some things that result in
changes to the underlying database the DataGrid is using
as a data source. When the popup window is closed I want
to refresh the main window -- i.e., cause a postback to
happen.

Is this possible?

From a user-interface perspective the popup window works
very nice. I know that I could perform the same funtion
in the main window but that would be messy.

Jay
Nov 18 '05 #1
5 2491
If you get the window.opener object (also a window) you can use the
window.location.reload before you close the popup window.

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Shell/UI
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

"Jay" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
I have a situation where the user clicks on a button in a
DataGrid to launch a popup window via javascript. In the
popup window the user does some things that result in
changes to the underlying database the DataGrid is using
as a data source. When the popup window is closed I want
to refresh the main window -- i.e., cause a postback to
happen.

Is this possible?

From a user-interface perspective the popup window works
very nice. I know that I could perform the same funtion
in the main window but that would be messy.

Jay

Nov 18 '05 #2
If the grid on main window is just populated when the page loads, you just
call opener.location.reload() (javascript call) on pop-up and cause it to
reload the main page.

However, if it needs more work, i.e a postback like some button would have
caused it (say Button) and an event to handle, you could have a hidden
button control on main window:

<asp:Button ID="btnHidden" runat="server" />

and then an associated javascript function for it (also on main window)

function myPostBack()
{
<%=Page.GetPostBackEventReference(btnHidden,'')% >
}

This causes a postback event to be raised in behalf of the Button, when
myPostBAck is called. You could then call this on the pop-up window by:

opener.myPostBack();

and it causes the main window to be posted as if btnHidden would have been
clicked. So to handle this click you need to handle btnHidden's Click event.
of course, if you already have a Button (or other control) that does this,
you could cause the postback on behalf of it as well.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"Jay" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
I have a situation where the user clicks on a button in a
DataGrid to launch a popup window via javascript. In the
popup window the user does some things that result in
changes to the underlying database the DataGrid is using
as a data source. When the popup window is closed I want
to refresh the main window -- i.e., cause a postback to
happen.

Is this possible?

From a user-interface perspective the popup window works
very nice. I know that I could perform the same funtion
in the main window but that would be messy.

Jay

Nov 18 '05 #3
Note that for the Button to be hidden, it should have Visible="False" as
well. :-)

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
If the grid on main window is just populated when the page loads, you just
call opener.location.reload() (javascript call) on pop-up and cause it to
reload the main page.

However, if it needs more work, i.e a postback like some button would have
caused it (say Button) and an event to handle, you could have a hidden
button control on main window:

<asp:Button ID="btnHidden" runat="server" />

and then an associated javascript function for it (also on main window)

function myPostBack()
{
<%=Page.GetPostBackEventReference(btnHidden,'')% >
}

This causes a postback event to be raised in behalf of the Button, when
myPostBAck is called. You could then call this on the pop-up window by:

opener.myPostBack();

and it causes the main window to be posted as if btnHidden would have been
clicked. So to handle this click you need to handle btnHidden's Click event. of course, if you already have a Button (or other control) that does this,
you could cause the postback on behalf of it as well.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"Jay" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
I have a situation where the user clicks on a button in a
DataGrid to launch a popup window via javascript. In the
popup window the user does some things that result in
changes to the underlying database the DataGrid is using
as a data source. When the popup window is closed I want
to refresh the main window -- i.e., cause a postback to
happen.

Is this possible?

From a user-interface perspective the popup window works
very nice. I know that I could perform the same funtion
in the main window but that would be messy.

Jay


Nov 18 '05 #4
You may also just be able to just call the javascript postback that asp.net
creates using
__doPostBack("yourobjectname","") within your own javascript.

"Jay" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
I have a situation where the user clicks on a button in a
DataGrid to launch a popup window via javascript. In the
popup window the user does some things that result in
changes to the underlying database the DataGrid is using
as a data source. When the popup window is closed I want
to refresh the main window -- i.e., cause a postback to
happen.

Is this possible?

From a user-interface perspective the popup window works
very nice. I know that I could perform the same funtion
in the main window but that would be messy.

Jay

Nov 18 '05 #5
Definately, but only when there is at least one control at the Page that
requires this JavaScript to exist. A call to Page.GetPostBackEventReference
ensures that __doPostBack declaration is outputted (that's what the control
needing this declaration calls)

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist

"vMike" <Mi************@nospam.gewarren.com.delete> wrote in message
news:bp**********@ngspool-d02.news.aol.com...
You may also just be able to just call the javascript postback that asp.net creates using
__doPostBack("yourobjectname","") within your own javascript.

"Jay" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
I have a situation where the user clicks on a button in a
DataGrid to launch a popup window via javascript. In the
popup window the user does some things that result in
changes to the underlying database the DataGrid is using
as a data source. When the popup window is closed I want
to refresh the main window -- i.e., cause a postback to
happen.

Is this possible?

From a user-interface perspective the popup window works
very nice. I know that I could perform the same funtion
in the main window but that would be messy.

Jay


Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ashish | last post by:
Hi All, I have a server runnable textbox control. I also have a server side button object but I hook up javascript to it to show a modal dialog. Upon return it places the value in the textbox...
3
by: EMW | last post by:
Hi, Is it possible with VB.NET and Javascript to popup a window, after a buttonclick, in which the user writes some text in a textbox and then when that window is closed with a button, the text...
1
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at...
7
by: Drew Berkemeyer | last post by:
Hello, We have an application that we have written using ASP.NET. On one of our pages we open a popup window using javascript. The popup window has a save and a cancel button. Both of them are...
9
by: John Walker | last post by:
Hi, I have a datagrid with a radiobutton template column, with AutoPostBack set to TRUE. When the user clicks on a radiobutton the application will PostBack, and in the PostBack there will be...
6
by: SkeanDu | last post by:
Ok, here is my problem. I have an aspx page that displays a databound datagrid and in one of the datagrid column headers I have an image that when clicked opens up a modal web dialog (another...
6
by: Shawn | last post by:
Any ideas how I can have a button click on one open page force a postback on a different page.
2
by: Rob Roberts | last post by:
Is there any way to prevent a ButtonField in a GridView from doing a postback when clicked? I want to use my own onclick handler to call window.open('SomePage.aspx') to display a page in a new...
4
by: Frank | last post by:
Hello everyone, I have a problem that the window.opener variable is lost once my popup page has a postback. On multiple pages they address this problem but I cannot find a correct answer. ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.