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 have a SharePoint Document view that allow people to upload file. However, I have a Javascript variable that will control when can the people upload file.

If the javascript variable is being assigned a value, say "Close", the SharePoint Document view should either not display on the screen or the whole aspx file cannot be access.

However, if the javascript variable is being assigned a value, say "Open", the SharePoint Document view will be display and people can upload their files or click New document.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

You can hide the web part by making the css class for the web part as disply="none"

Check your javascript variable value in a function, when the value is "Close" then add the line,

document.getElementById(webpartid).style.display="none";

Here webpartid is the ID of the Web Part, which you can get from the source of the page, which will look something like this - MSOZoneCell_WebPartWPQ

To make it back to visible you can use the code,

document.getElementById(webpartid).style.display="inline";
share|improve this answer
    
Took quite a while before I get everything working. I notice that most of my webpart id looks more like WebPartWPQ? (where question mark represent a number). Also, to know the ID, I need to go to the client, execute that page, find that particular key word and then use your code above). –  Jack Mar 13 '12 at 8:00
    
good to know that you got it right. –  Deepu Nair Mar 13 '12 at 14:55
    
Thanks for your solution, maybe you can include a note informing that one need to be at the client side (meaning that one need to open a web browser and right-click select view source code) rather than viewing the source code of the page in the SharePoint Designer. –  Jack Mar 14 '12 at 2:34

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.