My .ascx is into folder /cms/context/ , and it is called Test.ascx (on .NET 4.0, WebForms).
When I try to add :
<%@ Register TagPrefix="iz" Namespace="IZ.WebFileManager" Assembly="IZ.WebFileManager" %>
<div>
<iz:FileManager ID="FileManager1" runat="server" Height="400" Width="600">
<RootDirectories>
<iz:RootDirectory DirectoryPath="~/images/" Text="My Documents" />
</RootDirectories>
</iz:FileManager>
</div>
I get :
System.NullReferenceException. An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Why? And how can I fix it? Thanks
P.S. if I put the same code on Master Page it works as well...
Stack Trace :
[NullReferenceException: Object reference not set to an instance of an object.] IZ.WebFileManager.FileView.OnPreRender(EventArgs e) +167 System.Web.UI.Control.PreRenderRecursiveInternal() +112 System.Web.UI.Control.PreRenderRecursiveInternal() +221 System.Web.UI.Control.PreRenderRecursiveInternal() +221 System.Web.UI.Control.PreRenderRecursiveInternal() +221 System.Web.UI.Control.PreRenderRecursiveInternal() +221 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4200
Here is the link where you can get that plugins. I just put the DLL into Bin folder and write that code into my Web User Control. Always used on Master Page, but in a WUC I have that trouble...
If you only specify namespace and assembly you will only get the ascx.cs part of the control and not the code-front file (.ascx) Since your code-behind file (.ascx.cs) is dependent on your code-front file (.ascx) to actually instantiate all the stuff you have declared, you need to include the Src in the register directive
<%@ Register Src="~/cms/context/Test.ascx" TagPrefix="iz" TagName="Test" %>
If you create your controls without a code-front file (what used to be called a "custom control") you can get by with only specifying namespace and assembly, but if you want to have the convenience of a code-front file ("user control") you need to specify the source.
All the built-in controls within the asp.net framework are created as Custom Controls which means that it was harder for Microsoft to write them (they couldn't use ascx files) but it's easier for us to consume them (single register line in web.config enables for all pages)
I'm pretty sure you are missing the source reference:
<%@ Register Src="~/cms/context/Test.ascx" TagPrefix="iz" TagName="Test" %>