By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,570 Members | 970 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,570 IT Pros & Developers. It's quick & easy.

Need help with Page Interaction using ASP.Net 2.0

P: n/a
In my design, page 1 is a web-based dashboard used to assign resources to an
organization. The dashboard includes information about the organization as
well as a list of all assigned resources. Included on page 1 is a lookup
button that will open a search menu to find additional resources to assign to
the orgaization. When I press the lookup button on page 1, I want to leave
page 1 open and open a new search page. On the search page, I want to
perform a search and get a list of resources to choose from to assign to the
organization on the first page. When I select the resource, I want to
automatically update tje listed of assigned resources on page 1. The key
here is that I want to keep both pages open at the same time as part of my
workflow.

Cross-page postbacks don't seem to work because it closes the submitting
page. Any recommendations? Any examples?

Thank you!
--
Tim Meagher
Jan 9 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
I use Javascript to get cross-page callbacks working. All this
server-side stuff gets on my wick.

On your pop-up page, in an init function called from body.onload you
can do something like

var CallHome;
function init()
{
this.CallHome = this.opener.getCallbackFunction(this);
}
and in your opening page
function getCallbackFunction(caller)
{
// add your own logic based on caller.name if you're
// going to have several control windows open
return updateResourceList;
}

function updateResourceList(resource)
{
// do what you have to do to update your list
// with the value(s) from resource
}

now, when the user selects a resource in your popup window you can call
CallHome() and pass the value that they've selected. The nice thing
about doing it this way is that neither page really cares about the
other, you can mix and match pages with callback functions as you
please. If your popup refreshes, or does a postback, it will
automagically dial home again to get the callback function.
AAOMTim wrote:
In my design, page 1 is a web-based dashboard used to assign resources to an
organization. The dashboard includes information about the organization as
well as a list of all assigned resources. Included on page 1 is a lookup
button that will open a search menu to find additional resources to assign to
the orgaization. When I press the lookup button on page 1, I want to leave
page 1 open and open a new search page. On the search page, I want to
perform a search and get a list of resources to choose from to assign to the
organization on the first page. When I select the resource, I want to
automatically update tje listed of assigned resources on page 1. The key
here is that I want to keep both pages open at the same time as part of my
workflow.

Cross-page postbacks don't seem to work because it closes the submitting
page. Any recommendations? Any examples?

Thank you!
--
Tim Meagher


Jan 9 '06 #2

P: n/a
Thank you for your recommendation. I'd like to try that approach but I'm
wondering if you have any fuller examples including the aspx source for both
the primary web page and the popup? I'm somewhat of a novice when it comes
to javascript.

Thx - Tim

--
Tim
"Flinky Wisty Pomm" wrote:
I use Javascript to get cross-page callbacks working. All this
server-side stuff gets on my wick.

On your pop-up page, in an init function called from body.onload you
can do something like

var CallHome;
function init()
{
this.CallHome = this.opener.getCallbackFunction(this);
}
and in your opening page
function getCallbackFunction(caller)
{
// add your own logic based on caller.name if you're
// going to have several control windows open
return updateResourceList;
}

function updateResourceList(resource)
{
// do what you have to do to update your list
// with the value(s) from resource
}

now, when the user selects a resource in your popup window you can call
CallHome() and pass the value that they've selected. The nice thing
about doing it this way is that neither page really cares about the
other, you can mix and match pages with callback functions as you
please. If your popup refreshes, or does a postback, it will
automagically dial home again to get the callback function.
AAOMTim wrote:
In my design, page 1 is a web-based dashboard used to assign resources to an
organization. The dashboard includes information about the organization as
well as a list of all assigned resources. Included on page 1 is a lookup
button that will open a search menu to find additional resources to assign to
the orgaization. When I press the lookup button on page 1, I want to leave
page 1 open and open a new search page. On the search page, I want to
perform a search and get a list of resources to choose from to assign to the
organization on the first page. When I select the resource, I want to
automatically update tje listed of assigned resources on page 1. The key
here is that I want to keep both pages open at the same time as part of my
workflow.

Cross-page postbacks don't seem to work because it closes the submitting
page. Any recommendations? Any examples?

Thank you!
--
Tim Meagher


Jan 9 '06 #3

P: n/a
Sorry for the delay, I've been snowed under.

For ASPX, you'll have to work something out yourself - if you need to
post on the opener page, call the __doPostback__() function added by
ASP.Net. For extra slickness points, try using Ajax to do the refresh
for the opener. Look up Client Callbacks for ASP.Net 2.0 or look at one
of the open libraries like Ajax.Net which is much nicer.

Here's the source for a quick and dirty demo of the javascript
technique, you can tidy this up immensely. I use a hashtable of window
names on opener pages and look up the function from that, but this will
work for one page.

<code>
<!-- 1.htm is the parent file -->
<html>
<head>
<script type="text/javascript">
var myChild;
function getCallback(window)
{
// note: no brackets - we want to return the function, not call
it
return updateReceiverBox;
}

// here's the function that handles the child response.
function updateReceiverBox(text)
{
document.getElementById("receiverBox1").value = text;
alert("got text:" +text);
}

function openChild()
{
myChild = window.open("2.htm");
// you can close or refresh or generally jiggle about with your
child window with the reference returned from window.open.
}
</script>
</head>

<body>
<input type="text" id="receiverBox1" />
<input type="button" id="btnOpenWindow" onclick="openChild()"
text="open child window" />
</body>
</html>
</code>
<code>
<html>
<head>
<script type="text/javascript">
// sendValue gets the return value from the page and passes it to the
function CallHome
//which is assigned by the opener. If you need to pass multiple values,
build a javascript
//object instead like
// var myobject = new object()
// myObject.SomeField = someValue;
// myObject.SomeOtherField = someOtherValue;
// CallHome(myObject);

function sendValue()
{
var text = document.getElementById("senderBox1").value;
CallHome(text);
}

// handshake sets the value of CallHome. Make sure this is called from
body.onload
// doing it from the child window means that your child can do
postbacks or refreshes
// and it will re-handshake when it loads again.
function Handshake()
{
this.CallHome = this.opener.getCallback(this);
}
</script>
</head>
<body onload="Handshake()">

<input type="text" id="senderBox1" />
<input type="button" onclick="sendValue()" value="send value" />
</body>
</html>
</code>
Hope that's some use to you. It's nice little tricks like this that
make me love javascript. Closures and first-class functions without
that whole Delegate mess. Bliss.

Jan 13 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.