Die_Antwoord
asked on
SharePoint 2010 Upload link
Hi,
We have a requirement where we would like to add an upload link in the menu. The code that I have is:
<a class="ms-addnew"
id="idHomePageNewDocument"
href="http://Site/Documents/_layouts/Upload.aspx?List={A6176004-C4B8-4684- 9396-8DB0B 207D75F}&a mp;RootFol der="
onclick="javascript:NewIte m2(event, "http://Site/Documents/_layouts/Upload.aspx?List={A6176004-C4B8-4684- 9396-8DB0B 207D75F}&a mp;RootFol der=" );javascri pt:return false;"
target="_self">Upload new doc</a>
This works, but I need to call this script on a “onload” event.
The other code that I have is:
<script language="javascript" type="text/javascript">
var addObj= document.getElementById("i dHomePageN ewDocument ");
if (addObj!=null) {
addObj.href="http://site/Documents/_layouts/Upload.aspx?List={A6176004-C4B 8-4684-939 6-8DB0B207 D75F}& RootFolder =";
addObj.onclick=null;
}
</script>
This code doesn’t do anything.
So what I really need to do is create a link in a menu to a page that has an onload event which opens the modal window for the upload.aspx
This cannot be that hard but I am not very good with Javascript.
We have a requirement where we would like to add an upload link in the menu. The code that I have is:
<a class="ms-addnew"
id="idHomePageNewDocument"
href="http://Site/Documents/_layouts/Upload.aspx?List={A6176004-C4B8-4684-
onclick="javascript:NewIte
target="_self">Upload new doc</a>
This works, but I need to call this script on a “onload” event.
The other code that I have is:
<script language="javascript" type="text/javascript">
var addObj= document.getElementById("i
if (addObj!=null) {
addObj.href="http://site/Documents/_layouts/Upload.aspx?List={A6176004-C4B
addObj.onclick=null;
}
</script>
This code doesn’t do anything.
So what I really need to do is create a link in a menu to a page that has an onload event which opens the modal window for the upload.aspx
This cannot be that hard but I am not very good with Javascript.
ASKER
Hi Mrugesh1,
Thank you for your quick response.
The thing is, don't want to click a link on the page, this should be an "onload" event.
Steps should be:
1. User selects upload link from menu.
2. Opens page with Javascript and "onload" loads Javascript that in return opens the modal window that contains the upload.aspx
Thank you for your quick response.
The thing is, don't want to click a link on the page, this should be an "onload" event.
Steps should be:
1. User selects upload link from menu.
2. Opens page with Javascript and "onload" loads Javascript that in return opens the modal window that contains the upload.aspx
As per my understing with ur question, below is the solution.
In upload.aspx page follow below steps,
1) In .aspx page, <body id="htmlBody" runat="server"> and under <head> part write below script
<script language="javascript" type="text/javascript">
function OpenWindow()
{
var myArguments = new Object();
window.showModalDialog("Yo urPageUrl" , myArguments, '');
}
</script>
2) In .aspx.cs page under Page_Load event, write...
htmlBody.Attributes.Add("o nload", "OpenWindow()");
In upload.aspx page follow below steps,
1) In .aspx page, <body id="htmlBody" runat="server"> and under <head> part write below script
<script language="javascript" type="text/javascript">
function OpenWindow()
{
var myArguments = new Object();
window.showModalDialog("Yo
}
</script>
2) In .aspx.cs page under Page_Load event, write...
htmlBody.Attributes.Add("o
ASKER
Hi Mrugesh1,
This is a SharePoint 2010 site and modifying the upload.aspx would make SharePoint unsuported.
Would I not be able to modify the following code to fire onload instead of onclick:
<script language="javascript" type="text/javascript">
function OpenLink()
{
var addObj= document.getElementById("i dHomePageN ewDocument ");
addObj.href="http://site/Documents/_layouts/Upload.aspx?List={A6176004-C4B 8-4684-939 6-8DB0B207 D75F}& RootFolder =";
}
window.onload="OpenLink()" >
<a class="ms-addnew"
id="idHomePageNewDocument"
href="#"
onclick="javascript:NewIte m2(event, "http://site/Documents/_layouts/Upload.aspx?List={A6176004-C4B8-4684- 9396-8DB0B 207D75F}&a mp;RootFol der=" );javascri pt:return false;"
target="_self">Upload new doc</a>
This is a SharePoint 2010 site and modifying the upload.aspx would make SharePoint unsuported.
Would I not be able to modify the following code to fire onload instead of onclick:
<script language="javascript" type="text/javascript">
function OpenLink()
{
var addObj= document.getElementById("i
addObj.href="http://site/Documents/_layouts/Upload.aspx?List={A6176004-C4B
}
window.onload="OpenLink()"
<a class="ms-addnew"
id="idHomePageNewDocument"
href="#"
onclick="javascript:NewIte
target="_self">Upload new doc</a>
ASKER
Is there any JavaScript Gurus out there?
I guess your basic necessity is to open a custom page which should again popopen a upload modal popup.
Its possible. try this:
You can redirect user with appripriate parameters to your custom page.
Now have a <img> control on that page, you can set its' display to none to hide it.
Now you can use the onload function for that image and write the script that you have in there.
What will happen is that as soon as user gets redirected to that page and our image loads, it will call the onload function and your code will execute.
Happy Coding!
Its possible. try this:
You can redirect user with appripriate parameters to your custom page.
Now have a <img> control on that page, you can set its' display to none to hide it.
Now you can use the onload function for that image and write the script that you have in there.
What will happen is that as soon as user gets redirected to that page and our image loads, it will call the onload function and your code will execute.
Happy Coding!
ASKER
Hi,
I need to add a link in SharePoint navigation that will enable the user to upload a document to a document library. This should open the SharePoint modal window.
This is a SharePoint 2010 solution. The user should end up on the page where he/she initiated the upload from.
The code that I have has is:
<a class="ms-addnew" id="idHomePageNewDocument"
href="http://site/Documents/_layouts/Upload.aspx?List={ListID}&RootFol der=&"
onclick="javascript:NewIte m2(event, "http://site/Documents/_layouts/Upload.aspx?List={ ListID }&RootFolder=");
javascript:return false;" target="_self">Upload new asset</a>
This code works but I am not able to get into the <a></a> tag of the navigation within SharePoint.
I need to add a link in SharePoint navigation that will enable the user to upload a document to a document library. This should open the SharePoint modal window.
This is a SharePoint 2010 solution. The user should end up on the page where he/she initiated the upload from.
The code that I have has is:
<a class="ms-addnew" id="idHomePageNewDocument"
href="http://site/Documents/_layouts/Upload.aspx?List={ListID}&RootFol
onclick="javascript:NewIte
javascript:return false;" target="_self">Upload new asset</a>
This code works but I am not able to get into the <a></a> tag of the navigation within SharePoint.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Closing due to another question posted.
<html>
<head>
<script language="javascript" type="text/javascript">
function OpenLink()
{
var addObj= document.getElementById("i
addObj.href="http://site/Documents/_layouts/Upload.aspx?List={A6176004-C4B
}
</script>
</head>
<body onload="OpenLink()">
<a class="ms-addnew"
id="idHomePageNewDocument"
href="#"
onclick="javascript:NewIte
target="_self">Upload new doc</a>
</body>
</html>