سؤال

I have a aspx page that have this piece of code to load a usercontrol loaded from 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);

and the ascx have an outputcache

<%@ OutputCache Duration=10 VaryByParam="none" %>

when i browse the page this error comes out

[NullReferenceException: Object reference not set to an instance of an object.] Content_SectionNews.Page_Load(Object sender, EventArgs e) in c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\AnaweenNews.root\AnaweenNews\anaween website\Content\SectionNews.aspx.cs:127 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14 System.Web.Util.CalliEventHandlerDelegateProxy.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

Version Information: Microsoft .NET Framework Version:2.0.50727.3615; ASP.NET Version:2.0.50727.3618

لا يوجد حل صحيح

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top