Solved

Create an "Upload a Document" button web part in other document libaries

Posted on 2013-01-15
3
3,009 Views
Last Modified: 2013-01-17
1. Created a subsite and used the "Document Center" template.
2. Exported the "Upload a Document" button from that site.
3. Uploaded the button web part to the Web Part Library.
4. On the Home page I added the "Upload a Button" web part.
5. The button works on the subsite fine.
6. On the home page the button will not open the "upload.aspx" page.

Here is a copy of the code for the button. They are exactly the same for both the home page and subsite.

<div class="ms-uploadbtnlink"><button onclick="javascript:OpenNewFormUrl(&#39;DropOffLibrary/Forms/upload.aspx&#39;);return false;" type="submit"><nobr><img alt="Upload a Document" src="/_layouts/Images/uploaddoc.png"/>&#160;<span>Upload a Document</span></nobr></button> </div>
0
Comment
Question by:mnoisette
3 Comments
 
LVL 11

Expert Comment

by:Guru Ji
ID: 38780222
You just have to specify the entire path for the form URL for upload.aspx in the home page.
For instance your website URL is

myintranet/home

and your subsite is

myintranet/departments/IT

then currently your upload for subsite pointing to
myintranet/departments/IT/DropOffLibrary/Forms/upload.aspx

you have to give FULL path on the code above
so that it knows which department or subsite library you trying to upload too.

Currently the URL is translated to

myintranet/DropOffLibrary/Forms/upload.aspx

and thats why it does not work
0
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 500 total points
ID: 38780306
Hi,
this is because the function "OpenNewFormUrl" is only defined on the doc center page (and not on the root site home page).

Thats the function in the doc center:
function OpenNewFormUrl(url)
{
	var options = {width:720, height:480};
	SP.UI.ModalDialog.commonModalDialogOpen(url, options, null, null);
}

Open in new window


Either you add the function to your home page or you recode the button click:
<button onclick="javascript:var options = {width:720, height:480};SP.UI.ModalDialog.commonModalDialogOpen('/DropOffLibrary/Forms/upload.aspx', options, null, null);return false;" type="submit">

Open in new window


Please be sure and check the Url of the DropOffLibrary.

HTH
Rainer
0
 

Author Closing Comment

by:mnoisette
ID: 38789689
Worked like a charm!
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For SharePoint sites, particularly public-facing ones, there are times when adding JavaScript, Meta Tags, CSS Styles or other content to the page <head> section is more practical than modifying master pages.  For instance, you could add the jQuery l…
Microsoft SharePoint Foundation 2010 and Microsoft SharePoint Server 2010 do not offer the option to configure the location of the SharePoint diagnostic trace log files during installation.  This can, however, be configured through Central Administr…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question