Turn Default Upload Overwrite Off in WSS 3.0
21-Aug-2008SharePoint 2007
By default the Overwrite checkbox in Upload.aspx is checked in WSS 3.0 and MOSS 2007, but sometimes you may want to change this default.
You’ll find some references on how to change this default, but they all seem to have the downside of having to modify one of the standard application pages which is unsupported and may be overwritten by a upgrade
So how do we change the default without modifying upload.aspx?
Once again the
<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Control Id="AdditionalPageHead" Sequence="100" ControlSrc="~/_controltemplates/DefaultUploadOverwriteOff/DefaultUploadOverwriteOff.ascx" />
</Elements>
The usercontrol we add is very simple it just add a javascript file to our pages:
<%@ Control Language="C#" %>
<script src="/_controltemplates/DefaultUploadOverwriteOff/DefaultUploadOverwriteOff.js"
language="javascript"
type="text/javascript">
</script>
Even the javascript file is very simple, it just loops throught all input-control on the page and if it’s the OverwriteSingle or OverwriteMultiple checkbox it unchecks it:
function DefaultUploadOverwriteOff()
{
var inputs = document.getElementsByTagName('input');
var i=0;
for (i=0;i<inputs.length;i++)
{
var input = inputs[i];
if (input.type == 'checkbox'
&& (input.id.indexOf('OverwriteSingle')>-1
|| input.id.indexOf('OverwriteMultiple')>-1))
input.checked = false;
}
}
_spBodyOnLoadFunctionNames.push('DefaultUploadOverwriteOff');
All the source is here and if you just want a solution file it’s here