Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 11th, 2008, 07:16 PM
Registered User
 
Join Date: May 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 6: Response Redirect and State

I have done a quick test of the Response.Redirect(Request.Url.ToString()) which returns you to the current page. In the book, the purpose of this code is to allow the user to change themes via the master page. In my test I included a textbox which carries its own state. The Redirect to the same page loses the state of the textbox as you might expect.

Is there any way to change the theme in a state safe way? Some users may get a little annoyed if they change the theme after having keyed data into a Web Form.

I was thinking you could disable the option once the user has started making changes to the page, but that doesn't seem like an easy or good idea to me.

Cheers,

Baz.

You can teach an old dog new tricks, sometimes.
 
Old May 11th, 2008, 08:40 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I would tend to make the argument that swapping themes is not something I would do while entering data, but of course, I am biased given that I understand the side-effect of the behavior you described.

The reason for the self redirect is that theme influence happens early on in the page life cycle. If you change the theme on a client postback event and don't do a full redirect then you will possibly have some strange behavior as the theme is only 'half-changed'.

One thing you could do is to force an additional postback. Add a button that is not visible and use the ClientScriptManager.GetPostbackEventReference method to get the client-side script for the click of that button and the ClientScriptManager.RegisterStartupScript method to emit this to the page when you change themes. This *should* result in an immediate postback (as if you manually clicked the button) which will give you a fresh page hit with the newly selected theme. I'm not sure if the control/event validation behavior introduced in ASP.NET 2.0 will interfere with this or not. Worth a try though.

-Peter
compiledthoughts.com
 
Old May 11th, 2008, 08:58 PM
Registered User
 
Join Date: May 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quick responses here, that is good! Thanks, Peter.

I know there is more to come on state in the book, so I will read on. In this case I know it is due to the nature of the request (changing the theme), which I think is a good option to offer users at any stage they may be at within a Web site. User experience is important in any software.

I suppose being aware of a problem (overstatement in this case) is the first step in avoiding it or dealing with it.

Cheers,

Baz.

You can teach an old dog new tricks, sometimes.
 
Old May 13th, 2008, 03:14 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Baz,

Another option you have is to move the Change Theme into the user's profile page (where you can set musical preferences and change your password). This way, it's clearly separated from other functionality.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.





Similar Threads
Thread Thread Starter Forum Replies Last Post
response.redirect sarah lee ASP.NET 1.0 and 1.1 Basics 1 October 27th, 2006 08:57 AM
response.redirect ava_h .NET Framework 2.0 0 October 18th, 2006 10:21 PM
response.redirect crmpicco Classic ASP Basics 3 February 9th, 2005 01:50 AM
Response.Redirect dhborchardt Classic ASP Basics 4 June 16th, 2003 05:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.