SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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,


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,

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


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.