Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Caching / August 2004

Tip: Looking for answers? Try searching our database.

Add A Web User Control to Server-Side Cache

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MLibby - 11 Aug 2004 02:21 GMT
I want to add a web user control to server-side cache using the following
code...

TextWriter tempWriter = new StringWriter();
Control control = LoadControl(acUrl);
control.RenderControl(new HtmlTextWriter(tempWriter));
sb.Append(tempWriter.ToString());
Context.Cache.Insert(acUrl, sb.ToString(), null,
DateTime.Now.AddSeconds(seconds), TimeSpan.Zero);

It works, almost! The web user control's code behind doesn't run and as a
result only the raw ascx file gets cached.  I've seen Portals use this form
of caching because it offers awesome control. But they typically subclass the
user control and override the control's prerender and render methods when
caching. I'm trying to take a shortcut and cache the user control directly
from the ASPX form. Please let me know if you have any ideas.

Mike
Signature

mcp, mcse, mcsd, mcad.net, mcsd.net

[MSFT] - 11 Aug 2004 09:13 GMT
Hi Mike,

In this way, you just put a string  in the ASP .NET cache, not the web
control. I think we have to subclass the web control and override its
render method. Then, get the string from cache and use as result of render
method, instead of rendering the control actually.

Luke

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.