473,320 Members | 1,922 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Is my logic correct on this page in terms of execute order?

I've been struggling with a page that is set up like this:

PAGE:
------------------
control 1 - reads a cookie and executes stuff based on that
control 2 - reads the same cookie and can also set the value
------------------

So, the logical layout for control 2 was this:

CONTROL 2:
-------------------
on page_load
- read the cookie
- based on the cookie, set the form values to match the current cookie

on buttonClick
- set the cookie to the new value
-------------------

The problem is that I *think* CONTROL 2 is executed in this order:

page load (do stuff)
button click
postback
page load (do stuff)
button click even handler (do stuff)

is that correct? If so, the issue is that the postback page reads the cookie
before setting it, so it's always one 'page view' behind.

My solution was to do the following. It works, but I'm wondering if I'm
completely not getting something obvious:

CONTROL 2:
-------------------
on page_load
if postBack
- set the cookie to the new value
- redirect to this page
else
- read the cookie
- based on the cookie, set the form values to match the current cookie
end if

on buttonClick
- do nothing but trigger the postback
-------------------

The logic being that I'm doing a postback to set the cookie, then a complete
refresh to then read the new setting. I'm only loading the page once in the
browser, but the server reads it twice.

I've had this similiar question before and came to conclusion that this is
about the best method. But before I get too set in my ways, I thought I'd
double check with the masses. I should note that I don't want to use any
javascript.

-Darrel
Nov 18 '05 #1
2 1434
there are two cookie collections. the request, what the browser sent (and is
read only), and the response, what you are sending back to the browser.

if you changed your logic to copy the request cookie to the response cookie,
then had your controls read the response cookie, then you would not need the
extra reload in the browser. even better would be a cookie manager class you
wrote that manged the cooike values.

note: a redirect causes the browser to reload the page, so the browser is
having to extra network requests (but not page renders)

-- bruce (sqlwork.com)
"darrel" <no*****@hotmail.com> wrote in message
news:ui**************@TK2MSFTNGP09.phx.gbl...
I've been struggling with a page that is set up like this:

PAGE:
------------------
control 1 - reads a cookie and executes stuff based on that
control 2 - reads the same cookie and can also set the value
------------------

So, the logical layout for control 2 was this:

CONTROL 2:
-------------------
on page_load
- read the cookie
- based on the cookie, set the form values to match the current cookie
on buttonClick
- set the cookie to the new value
-------------------

The problem is that I *think* CONTROL 2 is executed in this order:

page load (do stuff)
button click
postback
page load (do stuff)
button click even handler (do stuff)

is that correct? If so, the issue is that the postback page reads the cookie before setting it, so it's always one 'page view' behind.

My solution was to do the following. It works, but I'm wondering if I'm
completely not getting something obvious:

CONTROL 2:
-------------------
on page_load
if postBack
- set the cookie to the new value
- redirect to this page
else
- read the cookie
- based on the cookie, set the form values to match the current cookie end if

on buttonClick
- do nothing but trigger the postback
-------------------

The logic being that I'm doing a postback to set the cookie, then a complete refresh to then read the new setting. I'm only loading the page once in the browser, but the server reads it twice.

I've had this similiar question before and came to conclusion that this is
about the best method. But before I get too set in my ways, I thought I'd
double check with the masses. I should note that I don't want to use any
javascript.

-Darrel

Nov 18 '05 #2
> if you changed your logic to copy the request cookie to the response
cookie,

I might not quite be understanding that, but I think that's part of the
problem. I'm reading the cookie, so I can set the form to the same option as
the current cookie. Then, I reset the cookie if the form option has been
changed by the user. So It doesn't seem like I can directly copy it.
note: a redirect causes the browser to reload the page, so the browser is
having to extra network requests (but not page renders)


Is that true? I'm getting conflicting comments regarding that. The redirect
interupts the page processing on the server, so I assume this is only taking
place on the server (that and my browser shows only one page in the history
file).

But if it is additional network traffic, I should try and simplify this.

Thanks!

-Darrel
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jim | last post by:
im using asp.net, C# to enter data into a table in sql server...however im getting this error: Input string was not in a correct format. Description: An unhandled exception occurred during the...
60
by: Fotios | last post by:
Hi guys, I have put together a flexible client-side user agent detector (written in js). I thought that some of you may find it useful. Code is here: http://fotios.cc/software/ua_detect.htm ...
3
by: mca | last post by:
Hi everyone, I'm new to asp.net and i have a question about separating the html code from the programming code. i have an unknown numbers of entries in my table. I want to make a hyperlink...
15
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to...
10
by: Frank van Wensveen | last post by:
Friend, coders, fellow wage slaves, lend my your ears. I believe that in a perfect world the design of a website (or feature on a website) should be totally separated from its design and the data...
12
by: Bob Jones | last post by:
I have an odd business requirement and I think that the implementation is not correct in the terms of OOP development. Any help on the concepts would be very appreciated! We currently have a...
1
by: ryan1234 | last post by:
My ultimate goal is to get something like "ping.exe" to re-direct it's standardOutput in real time to an .aspx page. I've been able to get this behavior to work just fine in a regular console...
5
by: Donald Adams | last post by:
Hi, I will have both web and win clients and would like to page my data. I could not find out how the datagrid control does it's paging though I did find some sample code that says they do it...
4
by: Robert Stefko | last post by:
I am a student at NYIT and am taking a class on computer organization and architecture. The textbook we are using is very difficult and complicated to understand. I understand everything to a certain...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.