Use Namespace Aliases for Ambiguous Sitecore Class Names
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:
![]()
Got anything to say? Go ahead and leave a comment!
Recent Comments
- Performance tuning your Sitecore installation | Agile and ALM: Software development today on A Going Live Checklist for Sitecore Websites
- Imran Saleem on Sitecore Avanced Database Crawler Occasionally Provides Null Results
- Ty Cahill on Sitecore Front-End Development Best Practices
- Sitecore Managed Sites as Virtual Folders | Fire Breaks Ice on Sitecore Item and Field Names
- Krimos on Using the DataSource Field with Sitecore Sublayouts
Sitecore Links
- .Sitecore
- Aboo Bolaky
- Alex Shyba
- Anders Dreyer
- aweber1.0
- Brian Pedersen
- Christopher Wojciech
- Coffee => Coder => Code
- Dev Sitecored²
- Everything Web
- Image0.com blog
- John West
- Learn Sitecore
- Let's do Sitecore
- Mark van Aalst
- Matthew Kenny
- Molten Core
- Project Lifecycle
- Sean Kearney
- Sebastian Patten
- Sitecore Australia
- Sitecore Blog
- Sitecore Climber
- Sitecore Development
- Sitecore Gadgets
- Techphoria414
- The Client View
- The Sitecore Experience
- Web Content Management and Delivery
Archives
- April 2013 (1)
- February 2013 (1)
- January 2013 (1)
- December 2012 (1)
- June 2012 (2)
- May 2012 (2)
- March 2012 (1)
- February 2012 (1)
- January 2012 (5)
- December 2011 (4)
- November 2011 (1)
- July 2011 (1)
- June 2011 (1)
- May 2011 (2)
- March 2011 (6)
- February 2011 (2)
- January 2011 (10)

Posted under: