Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9271349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:35:57+00:00 2026-06-18T15:35:57+00:00

I’ve deployed a sharepoint web page and added a custom webpart that visualized data

  • 0

I’ve deployed a sharepoint web page and added a custom webpart that visualized data the way customers want to see it. The problem with the webpart is that we cannot scale, modify, or hide it when the user wants to. We thought to embed the Sharepoint webpart in a Java wrapper. Typically this would be easy on a standard HTML page. The question is how do I embed a webpart inside a java wrapper in Sharepoint?

I want to add 2 html buttons, one to show the webpart and one to hide the webpart. The challenge is finding the webpart ID that I can pass to either button to execute the hideMe or showMe java script.

The webpart header:

<WebPartPages:WebPartZone runat="server" Title="loc:FullPage" ID="FullPage" FrameType="TitleBarOnly"><ZoneTemplate>
<WpNs0:Trend runat="server" __MarkupType="xmlmarkup" WebPart="true" __WebPartId="{AFA8DE0A-E7B4-4580-BFAB-038D96E72F0A}" >

The code (so far)

<button onclick="HideWebpart('AFA8DE0A-E7B4-4580-BFAB-038D96E72F0A')">Hide Me</button>
<button onclick="ShowWebpart('AFA8DE0A-E7B4-4580-BFAB-038D96E72F0A')">Show Me</button>

<script>
function HideWebpart(AFA8DE0A-E7B4-4580-BFAB-038D96E72F0A)
{
    var wp=document.getElementById(AFA8DE0A-E7B4-4580-BFAB-038D96E72F0A);
    wp.className = "hidden";
}

function ShowWebpart(AFA8DE0A-E7B4-4580-BFAB-038D96E72F0A)
{
    var wp=document.getElementById(AFA8DE0A-E7B4-4580-BFAB-038D96E72F0A);
    wp.className = "";
}
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T15:35:58+00:00Added an answer on June 18, 2026 at 3:35 pm

    Ok so you can give the WebPart an id=”mywebpart”, then simply use a JavaScript function to hide it.

    Example:

    <style type="text/css>
        .hidden { display:none; }
    </style>
    <script>
    function HideWebpart(id_of_webpart)
    {
        var wp=document.getElementById(id_of_webpart);
        wp.className = "hidden";
    }
    
    function ShowWebpart(id_of_webpart)
    {
        var wp=document.getElementById(id_of_webpart);
        wp.className = "";
    }
    </script>
    <WebPartPages:WebPartZone>
    ..The SVG WebPart... <--Add WebPart with id here
    </WebPartPages:WebpartZone>
    
    <button onclick="HideWebpart('PASS WEB PART ID IN HERE')"/>
    

    I believe the problem is you want to use the “__WebPartId=” attribute when getElementById will only look for the “id=” attribute. so go find an element by a custom attribute you will need to use the following instead of getElementById:

    function getElementByAttribute(attr, value, root) {
        root = root || document.body;
        if(root.hasAttribute(attr) && root.getAttribute(attr) == value) {
            return root;
        }
        var children = root.children, 
            element;
        for(var i = children.length; i--; ) {
            element = getElementByAttribute(attr, value, children[i]);
            if(element) {
                return element;
            }
        }
    

    Usage:

    getElementByAttribute("__WebPartId",'PASS WEB PART ID IN HERE');
    

    Note: It will be much slower compared to getElementById because you cannot make use of any index

    Or if you can use the jQuery library you can use simply $(‘[__WebPartId=”PASS WEB PART ID IN HERE”]’)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
I'm interested in microtypography issues on the web. I want a tool to fix:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want to construct a data frame in an Rcpp function, but when I
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.