Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > ASP.NET 4 General Discussion
|
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion 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 April 10th, 2013, 09:46 PM
Authorized User
 
Join Date: Apr 2013
Posts: 14
Thanks: 5
Thanked 0 Times in 0 Posts
Default getting values from cached usercontrol

For usercontrols that use the outputcache directive, how do you access properties on the control after it is cached? If it doesn't really exist on the page? I tried out the following code and it gave a null reference error the second time the button was clicked:

protected void Button1_Click(object sender, EventArgs e)
{
System.Diagnostics.Debug.WriteLine(WebUserControl1 .TextBox1Contents);

}
 
Old April 11th, 2013, 03:03 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You can't. Output caching caches the output (e.g. the generated HTML) which is then reused as-is.

If you need access to the control, you need to disable output caching.

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:
arius (April 11th, 2013)





Similar Threads
Thread Thread Starter Forum Replies Last Post
cached copy of Page dotnetDeveloper BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 April 12th, 2010 03:31 PM
Filtering Data after its been cached Durkee VB.NET 2002/2003 Basics 0 November 13th, 2007 05:57 PM
POST response cached keenlearner BOOK: Professional Ajax ISBN: 978-0-471-77778-6 0 March 27th, 2007 03:12 PM
stop my ASP page being cached crmpicco Classic ASP Basics 1 June 7th, 2005 06:07 PM
Re-Insertion of Cached Items flyin General .NET 0 October 1st, 2004 02:11 PM





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