Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB 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 November 5th, 2011, 02:01 PM
Registered User
 
Join Date: Nov 2011
Posts: 14
Thanks: 5
Thanked 0 Times in 0 Posts
Default changing the value of a seprate server control from within another control

for example i want to set label one to show the value of the theme, i am able to do it if i write the code inside the page load method, but not if i write it in the ThemeList_SelectedIndexChanged method, please elaborate.


protected void ThemeList_SelectedIndexChanged(object sender, EventArgs e)
{

HttpCookie preferredTheme = new HttpCookie("PreferredTheme");
preferredTheme.Expires = DateTime.Now.AddMonths(3);
preferredTheme.Value = ThemeList.SelectedValue;
Response.Cookies.Add(preferredTheme);
Response.Redirect(Request.Url.ToString());

// set label1 to show the value/name of theme

Label1.Text = preferredTheme.Value;

}
 
Old November 5th, 2011, 03:18 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Take another look at the line before the one that assigns the text to the label. The Redirect statement takes you to another page causing a new page request.

So theoretically it works in the event handler; it just doesn't work because of the redirect.

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!
 
Old November 5th, 2011, 10:04 PM
Registered User
 
Join Date: Nov 2011
Posts: 14
Thanks: 5
Thanked 0 Times in 0 Posts
Default

so as i undrestand it in this code Response.Redirect(Request.Url.ToString()); is essentially refreshing the page?

and also why is it that i can access the BasePage attributes from the MasterPage code behind file but i cant access the MasterPage attributes from the BasePage file? does it have something to do with them being in different assemblies?
 
Old November 7th, 2011, 04:55 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yes, it 'refreshes" by executing a brand new request for the exact same page.

I'll answer the other question in the separate thread you created.

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!
The Following User Says Thank You to Imar For This Useful Post:
ftaran (November 7th, 2011)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing content control GWts BOOK: Beginning ASP.NET 4 : in C# and VB 1 March 20th, 2011 07:53 AM
Help! Custom Server Control using User Control diehard ASP.NET 1.0 and 1.1 Professional 2 January 4th, 2006 12:33 PM
Changing Page Title From User Control [email protected] ASP.NET 1.0 and 1.1 Professional 5 October 11th, 2005 08:48 AM
Changing Control Property from another Frame Wandha ASP.NET 1.0 and 1.1 Basics 4 August 8th, 2003 01:34 AM
Changing Control Property from another Frame Wandha Forum and Wrox.com Feedback 1 August 5th, 2003 07:43 AM





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