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

Is there a way to know when a webpart gets focused? I've look around, but couldn't find anything helpful.

Thanks!

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

I had to do something similar recently when trying to hide the ribbon in SP 2010. I have a blog article about it here: http://www.thelineberrys.com/default-category/option-to-show-the-sharepoint-2010-ribbon-when-hidden-by-default-2.html

I can tell you the function

function OnRibbonMinimizedChanged(ribbonMinimized) 

get's called when you click on a webpart. I had found another function when an item is selected but I don't remember what it was because the OnRibbonMinimizedChanged was the one I needed to tap into.

I hope this helps get you down the path you need. Thanks.

share|improve this answer
1  
Oops, just realized that you said c# and I gave you a JS function. I don't think there is a c# event for when a webpart get's focused, only a JS event. –  Steve Lineberry Jun 7 '12 at 17:32
    
yeh...I can go with two functions, either when ribbon is shown for the webpart or when webpart comes in to focus....Both would mean the same thing, if webpart comes into focus, then the ribbon shows....But it has to be backend....I'm guessing it might not be possible because there is no postback.... –  Pathachiever11 Jun 7 '12 at 17:51
1  
Yes, you are correct about the postback. You could do what I did with a delegate function and override the ootb one. Then in your own method you could do an ajax call to something that can handle your server side code. What are you actually trying to accomplish? –  Steve Lineberry Jun 7 '12 at 18:00
    
I have a ribbon attached to the webpart...The ribbon's buttons disable/enable depending on the selections made inside the webpart (using javascript)....However, with two or more wps on the page, the ribbon doesn't get updated automatically when a different webpart is selected...I want to automatically update the ribbon when the wp gets focus....currenly im playing with your code, maybe I can get something to work... –  Pathachiever11 Jun 7 '12 at 18:08
    
Even though I didn't use your approach, you're answer helped me find my answer...I used EventBug in firefox to see which even gets fired when we click a webpart, then I overrided that event and made my custom call. –  Pathachiever11 Jun 7 '12 at 19:26
show 1 more 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.