Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am looking to hide the "Upload" button in Asset Selector Dialog and I know Asset Selector Dialog uses Dialog.master in SharePoint. Is there a possibility to attach some custom jQuery/Javascript script which will hide the upload button on Asset Selector Dialog

Note: I don't want to modify OOTB Dialog.master page

The location of Asset Selector Dialog in layouts folder is test/_layouts/AssetPortalBrowser.aspx

Update: I have the script to hide the upload button but I just want to know how to put it in Dialog.Master? The problem is there exist no delegate control in Dialog.master at the moment which I can use to insert script.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Have you tried solving the script issue using Custom Action with Location="ScriptLink". It load the javascript on all the site pages and even the dialogs. See I have solved the problem below:

All you need to do is to change the paths accordingly, of course put these custom actions in a feature (Site Collection/Web) :)

  <CustomAction Location="ScriptLink" ScriptSrc="~SiteCollection/_layouts/js/jquery-1.5.2.js" Sequence="105" />

  <CustomAction
 Location="ScriptLink"
 ScriptBlock="function loadImageUploaderScript() {       
                      var head = document.getElementsByTagName('head')[0];          
                      var script = document.createElement('script');          
                      script.type = 'text/javascript'; 
                      var url = window.location.toString();
                      url = typeof(L_Menu_BaseUrl) != 'undefined' ? L_Menu_BaseUrl : url.substr(0, url.indexOf('/_layouts')); 

                      script.src = url + '/_layouts/js/DefaultUploadOff.js';                          
                      head.appendChild(script);                      
            }   
 _spBodyOnLoadFunctionNames.push('loadImageUploaderScript()');" Sequence="120">

DefaultUploadOff.js file will look like as follows:

jQuery(document).ready(function () {
    jQuery("#SiteMgr_Upload_ButtonTable").hide();

});

And if your jQuery doesn't work then you can use the following JavaScript code in DefaultUploadoff.js

var inputs = document.getElementsByTagName("table");
var i = 0;
for (i = 0; i < inputs.length; i++) {
var input = inputs[i];
if (input.id.indexOf('SiteMgr_Upload_ButtonTable') > -1)     
    document.getElementById('SiteMgr_Upload_ButtonTable').style.visibility = "hidden";
}
share|improve this answer
    
Oh great man! you are a guru! it is working like a charm :D :D. Many thanks!!!! –  Geek May 22 '12 at 15:16
    
Glad it helped your cause! –  Falak Mahmood May 22 '12 at 16:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.