C# has a nice feature where you can define a custom alias to a specific class in the usings section of a class. This is called a namespace alias and it can be leveraged to override class name conflicts within a class. Say you have a Sitecore codebehind that is using System.Web.UI.WebControls
and using Sitecore.Web.UI.WebControls
. If you make a reference to Image
, there’s a class name conflict:
One option is to write out the fully qualified name with the full namspace. Another option is to tell the class that Image
should specifically reference Sitecore.Web.UI.WebControls.Image
:
Now the compiler and IntelliSense knows exactly what Image
means:
If for some reason you need to reference both a regular ASP.NET Image and a Sitecore image, you can do something like this: