Comment utiliser OutputCache dans un UserControl dans ASP.NET
-
12-11-2019 - |
Question
J'ai une page ASPX qui a ce morceau de code pour charger un UserControl chargé à partir de la base de données
Control userControl = new Control();
userControl = LoadControl(userControlName);
((HiddenField)userControl.FindControl("HiddenFieldCategoryID")).Value = categoryID.ToString();
((HiddenField)userControl.FindControl("HiddenFieldNewsID")).Value = newsID.ToString();
((HiddenField)userControl.FindControl("HiddenFieldTypeID")).Value = typeID.ToString();
PlaceHolder3.Controls.Add(userControl);
Et l'ASCX a un OutputCache
<%@ OutputCache Duration=10 VaryByParam="none" %>
Quand je navigue sur la page, cette erreur sort
NullReferenceException: la référence d'objet n'est pas définie sur une instance d'un objet.] Content_SectionNews.Page_load (expéditeur d'objet, EventArgs e) dans C: Documents and Settings Administrator My Documents Visual Studio 2005 Projects anaweennews.root anaweennews Anaween Site Web Content sectionNews.aspx.cs: 127 System.web.util.callihelper.EventargFonctionCaller (Intptr FP, Object O, Object T, EventArgs E) +14 System.Web.util.CallentiventHandlerDelegateProxy.Callback (Object Sender, Eventargs E) +35 System.Web.Ui.Control.onLoad (EventArgs E) +99 System.Web.Ui.Control.LoadRecursive () +50 System.Web.Ui.Page.ProcessRequestmain (Boolean IncludeStagesBeforeasyncPoint, Boolean includestagesafterasyncpoint) +627
Informations sur la version: Microsoft .NET Framework Version: 2.0.50727.3615; Version ASP.NET: 2.0.50727.3618
Pas de solution correcte