11/25/2014

"Open with Explorer" and "Upload Multiple Documents" links availability check

When you create custom UI for SharePoint libraries you probably may need to create your own "Open with Explorer" and "Upload Multiple Documents" (the second link and functionality is available only in SharePoint 2010, not 2013) links. There are rules when these links are visible and operations are enabled: it should be IE and even not any version of it. You can search the rules and write your own code or use javascript function that is written by Microsoft and used in out-of-the-box link. It's named SupportsNavigateHttpFolder
You can use it something like that on server side:

ScriptManager.RegisterStartupScript(this, this.GetType(), "CheckOpenInExplorerAvailability",  
@"<script type='text/javascript'>  
var displayOpenInExp = SupportsNavigateHttpFolder() ? 'block' : 'none';   
var elOpenInExp = document.getElementById('" + controlId + @"');   
elOpenInExp.style.display = displayOpenInExp;  
</script>", false);  
or on the client (here I'm using jquery):
$('#' + controlId)[(SupportsNavigateHttpFolder() ? 'show' : 'hide']();
Have fun!

No comments:

Post a Comment