Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Hide a webpart

  Asked By: Urjita    Date: Sep 11    Category: Sharepoint    Views: 1924

Is there a way to add a webpart to the page and then not display this
webpart on the page until a click event happens within another webpart -
someone said something about putting the webpart within <div> tags and
then displaying that <div> tag....not sure if that will work.



2 Answers Found

Answer #1    Answered By: Liana Alston     Answered On: Sep 11

The web part class has a hidden property. All you need to do is toggle that
property from true to false. Just like any other control. Here's what I would

1) Have the webpart  built so it displays when placed on the page.

2) When a connection is established to another webpart on the page  toggle
the hidden property to true. The webpart will now disappear. (It may still
show up when the webpart page is in design mode).

3) Have the other webpart setup to send something across the connection
like when you click  on something. Have the hidden receiving webpart setup to
toggle hidden to false when it receives the connection value.

Answer #2    Answered By: Daamodar Kolhe     Answered On: Sep 11

There's always the simple Javascript way... you could add  an onclick event
handler to an element and then when it fires, call a Javascipt function that
makes the second element visible.

Of course the catch here is that you want your web part hidden at first, so
it needs to be rendered but invisible. You might be able to use "minimized"
mode for this; I'm not sure if the page  does a postback, but you could find
out pretty easily. If that doesn't work, then you can either (a) keep the
webpart in its own zone and surround that with a div whose display
properties you manipulate, or (b) get the ID of the webpart  itself and
manipulate its visibility directly.

That should get you pointed in the right direction (or at least give you
some things to think about before deciding). If you want more detail, just

Didn't find what you were looking for? Find more on Hide a webpart Or get search suggestion and latest updates.