I'm trying to make a web part that is managing other web parts in the solution. I need it to be able to hide other web parts based on user input. Since I can't use connections I'm trying to do this using SPLimitedWebPartManager. I got it to work but i need a double postback to get the effect, since saving the settings does not take effect before it has been loaded once more.

Does any one of you know other ways of hiding web parts (in combination of using the SPLimitedWebPartManager, need the personal settings) in one postback?

  • 1
    Please describe in which event (OnLoad, control event...) that you make the changes to the Web Part? Feb 16, 2010 at 9:08
  • It is on a on click event in a custome managing webpart
    – gaotter
    Feb 17, 2010 at 6:35

1 Answer 1


Did you try

webPart.Hidden = true;

If its only a visual thing (as in not security related) you could also opt for a jQuery approach where you hide the webpart DIV using javascript and dhtml.

  • Yes the code abow is the same as I use. The problem there is that the webpart manager has already setup all the webparts, so the effect of the save is only shown next time you have a postback (I'm now doing a redirect after the save now). The jQuery approach compinde with the web part manager may be the only way to go? I will try it out. I have to learn more javascript :).
    – gaotter
    Feb 17, 2010 at 6:43
  • well i didnt mean web part manager and jQuery, i dont think thats possible. I ment simply hiding the web parts clientside instead of server side Feb 17, 2010 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.