SharePoint: SPList.HasView() extension method
One quick posting. I wrote yesterday extension method for SharePoint that checks if view exists. I think it is far better for performance if I don’t live on try…catch to find out if view exists or not. Extension method that you have to put in static class is here.
public static bool HasView(this SPList list, string viewName)
foreach (SPView view in list.Views)
if (view.Title.ToLowerInvariant() == viewName.ToLowerInvariant())
One thought on “SharePoint: SPList.HasView() extension method”
But i think the performance would be bad when you have 1000+ views. try catch ftw!