• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 589
  • Last Modified:

How to hide and show webpart

I want to hide and show the search core results webpart based on the scope user choose in the Advanced Search page.
For example in the Advanced Search page I have multiple scopes
1) Scope1
2) Scope2
3) Scope3

When user choose Scope1 then the searchcore reullts1 webpart should show and hide the two other search core results webparts. How is it possible.

  • 2
2 Solutions
As I understand you would like to hide specific web parts depending on the scope passed in the URL of the search, right?
If so you can do it 2 ways - either code it (for ex create a web part that will read the query string and will hide the selected web parts, or use a javascript to check the URL, find the scope and use the style.display='none' for the selected web parts
Load your page in browser and then view source. You will find how SharePoint renders the page into HTML, such as the tags it generates for each web parts, etc. Then you just need to add javascripts into your page to hide and show the web parts.
One remark to thman comment - web part ID's are generated dynamicaly and can change when you for example change layout, web part order or even save the page, so you might brake your solution by simply moving the web part.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now