Don't want to use querystring variables...

T

TPS

I don't want to use QueryString variables to pass data from page to page
because the user can see and manipulate it. ( I know I can check for valid
data, and I do).

What other methods are people using to pass ID's around there apps from page
to page, like when a user clicks on a link, I need to be able to pass that
ID associated with that link back to my app, so I can build more child
links.

Thanks.

TPS.
 
M

Martin Marinov

All depends on the scenraio of your application.
You can pass values through session objects, but the you have to destroy
them or to manage them correctly because you can mess a previous call to a
page with next call just because of old values in a session object
Other way is to use Server.Transfer method, which will pass whole Request
collection to the next page, you can directly get the information you want
to. In this case the url for the page will not be changed

Regards
Martin
 
M

Mark Rae

I don't want to use QueryString variables to pass data from page to page
because the user can see and manipulate it. ( I know I can check for valid
data, and I do).

What other methods are people using to pass ID's around there apps from page
to page, like when a user clicks on a link, I need to be able to pass that
ID associated with that link back to my app, so I can build more child
links.

Well, the obvious answer is form submission. Instead of a link, have a
submit button which submits the page back to itself (or to another page, if
you prefer), then interrogate the Request.Forms collection server-side.

Or, if you don't want a submit button, have the hyperlink call a JavaScript
function passing in the value you're interested in. That function can
populate a hidden text box in your form and then submit the form to achieve
the same effect.
 
T

TPS

Martin,
Thank you for your ideas. I am using the session route now, and yes it is
difficult keeping it accurate.

Thanks again.

TPS.
 
T

TPS

Mark,

I like your idea of the JavaScript passing the value to a hidden var.

Thanks.

TPS
 
M

Mark Rae

TPS,
I like your idea of the JavaScript passing the value to a hidden var.

I promise you, this is not my idea! This is a totally standard way of
achieving what you want :)

<html>

<head>
<script>
function submitForm()
{
document.frmTest.txtHiddenValue.value = 'Hello'; // or
whatever
/*
do any other client-side stuff e.g. validation here
*/
document.frmTest.submit();
}
</script>
</head>

<body>
<form id=frmTest>
<input type=hidden id=txtHiddenValue runat=server>
<input type=button id=cmdSubmit value=Submit
onClick="submitForm();">
</form>
</body>

</html>

Then, when you submit the form, interrogate the value of txtHiddenValue in
the Page_Load event:

if (Page.IsPostBack)
{
string strHiddenValue = Request.Form["txtHiddenValue"].ToString();
}
 

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

Top