Skip to main content

Turn Default Upload Overwrite Off in WSS 3.0

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 controls in the default masterpage can help us. This time it’s the AdditionalPageHead delegate we can use. This delegate allows you to add any number of usercontrols to the page header of every page in sites where your feature is activated. So we add a feature with the following elements.xml file:

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="">
    <Control Id="AdditionalPageHead" Sequence="100" ControlSrc="~/_controltemplates/DefaultUploadOverwriteOff/DefaultUploadOverwriteOff.ascx" />

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"

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&lt;inputs.length;i++)
    var input = inputs[i];
    if (input.type == 'checkbox'
     &amp;&amp; ('OverwriteSingle')&gt;-1
      input.checked = false;

All the source is here and if you just want a solution file it’s here

Copyright © 2007-2022