Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question
    
Please describe in which event (OnLoad, control event...) that you make the changes to the Web Part? –  Wictor Wilen MCA MCM MVP Feb 16 '10 at 9:08
    
It is on a on click event in a custome managing webpart –  gaotter Feb 17 '10 at 6:35
add comment

1 Answer 1

Did you try

webPart.Hidden = true;
webPartManager.SaveChanges(webPart);

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.

share|improve this answer
    
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 '10 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 –  Anders Rask Feb 17 '10 at 13:59
add comment

Your Answer

 
discard

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.