If you do there is a better way as described by Per Jakobsen here.
Using the AdditionalPageHead delegate control to inject javascript to the page through a feature not only gives you a supportable system but allows you to switch the default to checked or not checked by activating or deactivating the feature.
I tried a variation of this on a SharePoint 2007 installation and it worked fine, after an upgrade to 2010 it stopped working however. Having spent five minutes trying to debug the issue I decided it would be swifter to just change it to use jQuery's $(document).ready function rather than solve the specific problem. There seems to be others having weird things going on with _spBodyOnLoadFunctionNames.push in 2010, so this is probably a quicker fix (at least if you've already got jQuery available on the page). If you don't you could add a reference to it in the DefaultUploadOverwriteOff.ascx user control.
The change to Jakobsen's javascript is simple, just replace the function DefaultUploadOverwriteOff() with this:
1
2
3
4
5
6
| $(document).ready(function() { if (document.title == "Upload Document") { $("input[id$='OverwriteSingle']").attr("checked",false); $("input[id$='OverwriteMultiple']").attr("checked",false); }}); |
and remove the last line: _spBodyOnLoadFunctionNames.push('DefaultUploadOverwriteOff');
This now works fine on both 2007 and 2010.
No comments:
Post a Comment