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

How can I perform some form actions on a seperate page?

P: n/a
Hi all,

I've got a form which lists all members of a club, with checkboxes to
select them. The form offers functions to delete selected members,
send email, etc.

Now I want write some code to perform complex analyses on the selected
members. I'd prefer to keep this code seperated from the basic form
processing, opening a new page with the results.

How should I go about doing this? I have a whole line of buttons for
the functions, and one of them should open a new page, how do I do
that? And how do I get the selection information from the overview
page to the analysis page?

Thanks, Peter

May 31 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
store the data in sesson, and do a redirect to the new page.

-- bruce (sqlwork.com)

Peter Bremer wrote:
Hi all,

I've got a form which lists all members of a club, with checkboxes to
select them. The form offers functions to delete selected members,
send email, etc.

Now I want write some code to perform complex analyses on the selected
members. I'd prefer to keep this code seperated from the basic form
processing, opening a new page with the results.

How should I go about doing this? I have a whole line of buttons for
the functions, and one of them should open a new page, how do I do
that? And how do I get the selection information from the overview
page to the analysis page?

Thanks, Peter
May 31 '07 #2

P: n/a
Careful here - don't mistake server functionality (i.e. analysing the
members) with client functionality (i.e. opening a new browser
window).

I would suggest you use some javascript to create a querystring of the
members you wish to analyse, then use the onclick event of the button
to execute it. Note: you'll get a warning if the button is set as
runat="server" but if you run it like a normal HTML button, it'll work
fine.

Off the top of my head (so excuse any typos or syntactical errors)
something like:

<head>
<script type="text/javascript">
function AnalyseMembers() {
// Get an array of all Checkboxes of a certain name on the page
var cbArray = document.getElementsByName("chkUserID");

// get comma seperated list of all selected user IDs
for (var i = 0; i < cbArray.lenght; i+) {
if (cbArray[i].checked) {
qs += cbArray[i].value + ",";
}
}

// remove trailing comma
if (qs != '') {
qs = qs.subString(0, qs.length - 1)
}

window.open('analysemembers.aspx?UserList=' + qs);
}
</script>
</head>
<body>
<form>
<input type="button" name="btnAnalyseMembers" value="Analyse Members"
onclick="AnalyseMembers();" />
</form>
</body>
If you really want to run it as an asp button, you should do the
btnAnalyseMembers.Attributes.Add("onclick", "AnalyseMembers();"); in
your Page_Load -!Page.IsPostBack

Hope that helps,

D

On 31 May, 14:30, Peter Bremer <peter.bre...@gmail.comwrote:
Hi all,

I've got a form which lists all members of a club, with checkboxes to
select them. The form offers functions to delete selected members,
send email, etc.

Now I want write some code to perform complex analyses on the selected
members. I'd prefer to keep this code seperated from the basic form
processing, opening a new page with the results.

How should I go about doing this? I have a whole line of buttons for
the functions, and one of them should open a new page, how do I do
that? And how do I get the selection information from the overview
page to the analysis page?

Thanks, Peter

May 31 '07 #3

P: n/a
What if a user has more than one window open?

D

On 31 May, 16:09, bruce barker <nos...@nospam.comwrote:
store the data in sesson, and do a redirect to the new page.

-- bruce (sqlwork.com)

Peter Bremer wrote:
Hi all,
I've got a form which lists all members of a club, with checkboxes to
select them. The form offers functions to delete selected members,
send email, etc.
Now I want write some code to perform complex analyses on the selected
members. I'd prefer to keep this code seperated from the basic form
processing, opening a new page with the results.
How should I go about doing this? I have a whole line of buttons for
the functions, and one of them should open a new page, how do I do
that? And how do I get the selection information from the overview
page to the analysis page?
Thanks, Peter- Hide quoted text -

- Show quoted text -

May 31 '07 #4

P: n/a
ASP.NET implements a new server-side page cache object, that has a
different life line than the session object. Using both, you can
persist data between pages for indefinite amounts of time, even if the
session object gets destroyed because of timeouts.

Assign each user a GUID (or any unique identifier) and store this
value in a session object with a well known key:

Session["USERGUID"]=new System.Guid(strUsersGUID)

then, you use the GUID to identify a particular page cache which holds
the data:

dim xmlDoc as XmlDocument=null
if not session["USERGUID"] is nothing then
dim strUserGUID as System.String=session["USERGUID"] 'get the key
to access the page cache
dim xml as System.String = Page.Cache[strUserGUID].ToString()
'retrieve your data from the page cache
XmlDocument.LoadXml(xml) 'instantiate your data
endif

before you unload your page, you can save your data in the page.cache
(and optionally destroy the session object):

Page.Cache[strUserGUID]=xmlDoc.OuterXml 'save your data to the page
cache
session["USERGUID"]=null 'destroying the session still preserves your
page cache
response.redirect("newpage.aspx")

and have the new page repeat the steps to get the page.cache in its
page_load function.

The page.cache persists using a different timer than the session
object, and if you re-establish the session you can get a reference to
an existing page cache. So, you can set the session to timeout in 5
minutes of inactivity and have the page cache timeout after one hour
of inactivity. The page cache cannot be accessed without the key in
the session object, so the session object provides security against
the user being inattentive and the page cache provides a mechanisim to
preserve the data between pages regardless of how long transmission
takes or the time between transations.

B.T.W. You don't have to use an XML document to store data in the page
cache, but it sure makes it easier to store and deliniate an arbitrary
number of fields simultaneously without passing them around in posts
or the hidden viewstate field in ASP.NET

May 31 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.