I have a series of composite user controls that inherit from a base class which override the Render method of the control. I have put a Substitution control on one of those composite controls; however the substitution content is being written to the top of the output stream instead of where the substitution control is defined. Below is my render method.
In essence what I’m aiming for is donut caching while overriding the Render method on the user controls.
Any thoughts on why this is happening despite the fact that the base render method is being invoked?
protected override void Render(System.Web.UI.HtmlTextWriter writer) {
System.IO.StringWriter sw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htw = new System.Web.UI.HtmlTextWriter(sw);
base.Render(htw);
string output = sw.ToString();
try {
MyPage objPage = (MyPage)this.Page;
CustDictionary d = new CustDictionary(objPage);
output = d.Replace(output);
}
catch {
// do nothing
}
writer.Write(output);
}
From reviewing Google and a fair bit of testing I did, it seems this is not possible in asp.net 3.5. The goal was to have a control that wasn’t cached, either using the substitution control or by inheriting from a similar control. There are methods of doing this making use of inheritance and other custom controls, but it would require an instantiation of the page within the control to hand-render the control, which would put an unnecessary strain on the application. The end solution for this was to print out the data which was already in a cookie using jQuery.