Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > ASP.NET 4 General Discussion
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 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 April 10th, 2013, 09:46 PM
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 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);

}
Reply With Quote
  #2 (permalink)  
Old April 11th, 2013, 03:03 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 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!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
arius (April 11th, 2013)
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
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



All times are GMT -4. The time now is 05:49 PM.


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