Refresh GridView from pop-up

D

David C

I have an asp.net web page that contains a GridView showing data from a
database. I have a LinkButton in one of the GridView columns that has
OnClientClick = "return opentask();" which opens a pop-up aspx page using
the following Javascript.

function opentasks(srecordid) {
var surl = 'JobTasks.aspx?rid=' + srecordid;
void window.open(surl, "_blank",
height=475,width=760,status=yes,toolbar=no,menubar=no,location=no");
return false;
}

What I would like to do is when the JobTasks.aspx (FormView) does an insert
or update I would like to refresh ( DataBind()? ) the GridView (named
gvOpenorders) on the calling page.

Is there an easy way to do this and if so, how? Thanks.

David
 
L

Leon

I have an asp.net web page that contains a GridView showing data from a
database. I have a LinkButton in one of the GridView columns that has
OnClientClick = "return opentask();" which opens a pop-up aspx page using
the following Javascript.

function opentasks(srecordid) {
var surl = 'JobTasks.aspx?rid=' + srecordid;
void window.open(surl, "_blank",
height=475,width=760,status=yes,toolbar=no,menubar=no,location=no");
return false;
}

What I would like to do is when the JobTasks.aspx (FormView) does an insert
or update I would like to refresh ( DataBind()? ) the GridView (named
gvOpenorders) on the calling page.

Is there an easy way to do this and if so, how? Thanks.

David

Not sure if this would qualify for best answer, but since you are
using JavaScript windows I'd go for the next approach.

Add a button or linkbutton to your calling page and attach an event
handler to it (use dblClick on it) - think you might even be able to
hide the button; not sure about that though, so better test is visible
first -
in that eventhandler refresh the data for the grid. Let's call the
button RefreshGridButton

In the JobTasks.aspx you add a JavaScript something like the next:
<script type="text/javascript">
<!--
if (window.opener != null)
{
try
{
window.opener.javascript:__doPostBack('RefreshGridButton','');
---> handle catch

Think it should work (pretty untested though)

..L.
 
D

David C

Leon said:
Not sure if this would qualify for best answer, but since you are
using JavaScript windows I'd go for the next approach.

Add a button or linkbutton to your calling page and attach an event
handler to it (use dblClick on it) - think you might even be able to
hide the button; not sure about that though, so better test is visible
first -
in that eventhandler refresh the data for the grid. Let's call the
button RefreshGridButton

In the JobTasks.aspx you add a JavaScript something like the next:
<script type="text/javascript">
<!--
if (window.opener != null)
{
try
{
window.opener.javascript:__doPostBack('RefreshGridButton','');
---> handle catch

Think it should work (pretty untested though)

.L.

I will give that a try. I was even thinking of using an AJAX Timer control
to do a DataBind every xxx seconds that I could activate when I opened the
new window and then turned it off when I closed it. Not sure how I could
stop the Timer since it is on the "opener" page. Thanks.

David
 
D

David C

Leon,

It did not like

window.opener.javascript:__doPostBack('RefreshGridButton','');

It said 'expected ;' as a page error and it was referencing the colon :))
you have after the word javascript

David
 
L

Leon

Leon,

It did not like

window.opener.javascript:__doPostBack('RefreshGridButton','');

It said 'expected ;' as a page error and it was referencing the colon :))
you have after the word javascript

David

ofcourse it didn't like it..
it's either:
function namehere()
window.opener.__doPostBack('RefreshGridButton','');


or <a
href"javascript:window.opener.__doPostBack('RefreshGridButton','');

but never :javascript inside the function

the :javascript states: this <a href == is a script call; which
script??: javascript

..L.
 
D

David C

Leon said:
ofcourse it didn't like it..
it's either:
function namehere()
window.opener.__doPostBack('RefreshGridButton','');


or <a
href"javascript:window.opener.__doPostBack('RefreshGridButton','');

but never :javascript inside the function

the :javascript states: this <a href == is a script call; which
script??: javascript

.L.

Leon,
I changed it to below, but still no luck, however I am not getting any
errors. When I click the refresh button on the opener page it does refresh,
but not when I call it from this pop-up page. Below is my function I have in
the pop-up page.

function refreshorders() {
if (window.opener != null) {
window.opener.__doPostBack('LBtnRefreshOrders','');
}
}


David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top