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

P

Peter Bremer

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
 
B

bruce barker

store the data in sesson, and do a redirect to the new page.

-- bruce (sqlwork.com)
 
D

Dunc

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.checked) {
qs += cbArray.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
 
A

Andy

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
 

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

No members online now.

Forum statistics

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

Latest Threads

Top