Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 4.5 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4.5: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-31180-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4.5 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 10th, 2013, 09:42 AM
Authorized User
Points: 65, Level: 1
Points: 65, Level: 1 Points: 65, Level: 1 Points: 65, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2013
Location: Northern Virginia
Posts: 14
Thanks: 5
Thanked 0 Times in 0 Posts
Default Chapter 4: State Engine

Following one of the Try it out exercise I set EnableViewState="false" for a label control. In the browser, the label's text property is set with some code. I then do a postback and the text property value returns to its original value as expected.

However the refresh button on the browser seems very interesting. I click that and the value of the label is preserved. It does not go back to its original value even though I turned off viewstate for it. Why is that ?

Thanks
Reply With Quote
  #2 (permalink)  
Old August 11th, 2013, 06:17 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

Which browser do you use? Maybe you're just getting the same page served again? What happens when you click Refresh while holding down control (or press Crl+F5 or Ctrl+R).

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #3 (permalink)  
Old August 11th, 2013, 06:41 AM
Authorized User
Points: 65, Level: 1
Points: 65, Level: 1 Points: 65, Level: 1 Points: 65, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2013
Location: Northern Virginia
Posts: 14
Thanks: 5
Thanked 0 Times in 0 Posts
Default

Using google chrome. When I press ctrl-R a dialog question box appears asking:

"The page that you're looking for used information that you entered. Returning to that page might cause any action you took to be repeated. Do you want to continue ?".

So I click Ok and the page refreshes. But I noticed something I did not before--the label text is slightly different, so this code gets fired again when refreshing:

Code:
Label1.Text = DateTime.Now.ToString();

I am guessing that firing the same code again when refreshing is a browser feature? and not an ASP.net feature?

Thanks so much
Reply With Quote
  #4 (permalink)  
Old August 11th, 2013, 06:56 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Yes, most, if not all, browsers have this to avoid sending the same post request twice. Imagine you just paid something on an eCommerce site and then refreshed the page. That means you could be paying twice. Browsers help you prevent this from happening by asking you for confirmation.

When you confirm, you re-execute the last action: in other words, it's as if you click the button again and thus the label gets updated.

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
arius (August 11th, 2013)
  #5 (permalink)  
Old August 11th, 2013, 07:20 AM
Authorized User
Points: 65, Level: 1
Points: 65, Level: 1 Points: 65, Level: 1 Points: 65, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2013
Location: Northern Virginia
Posts: 14
Thanks: 5
Thanked 0 Times in 0 Posts
Default

Thank you Imar
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 4 Basic Search Engine Help will1035 BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9 3 April 26th, 2012 06:42 AM
sessio state gurjant Forum and Wrox.com Feedback 0 March 5th, 2012 08:59 PM
Chapter 4 - View State Tulsi BOOK: Beginning ASP.NET 4 : in C# and VB 5 February 28th, 2012 03:04 AM
Chapter 6: Response Redirect and State BazNZ BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 May 13th, 2008 03:14 AM
Session State|View State|Do I have other options? rockon ASP.NET 1.x and 2.0 Application Design 2 October 5th, 2005 07:10 PM



All times are GMT -4. The time now is 07:46 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.