Come utilizzare OutputCache in UserControl in ASP.NET
-
12-11-2019 - |
Domanda
Ho una pagina ASPX che ha questo pezzo di codice per caricare un UserControl caricato dal database
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);
e l'ASCX ha un outputcache
<%@ OutputCache Duration=10 VaryByParam="none" %>
Quando navigo la pagina questo errore viene fuori
NullReferenceException: Riferimento oggetto non impostato su un'istanza di un oggetto.] Content_sectionnews.page_load (mittente oggetto, eventargs e) in c: documenti e impostazioni amministratore my documents Visual Studio 2005 Projects Anaweennews.root Anaweennews Sito Web Anaween Content sectionNews.aspx.cs: 127 System.Web.Util.Callihelper.EventArgFunctionCaller (Intptr FP, Object O, Object T, EventArgs E) +14 System.Web.Util.CalieventHandleDeleGaTroxy.Callback (Object Sender, EventArgs, EventArgs e) +35 System.Web.UI.Control.Onload (eventArgs E) +99 System.Web.Ui.Control.loadRecursive () +50 System.Web.ui.Page.ProcessRequestMain (booleano IncludeesbeForeasyncpoint, Boolean Include Aftesyncpoint) +627
Informazioni sulla versione: Microsoft .NET Framework Versione: 2.0.50727.3615; Versione ASP.NET: 2.0.50727.3618
Nessuna soluzione corretta