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

Have Webpart A & B that are derived from AbstractWebpart. Here is the scenario....add and configure several A/B webparts to the page. There is one webpart property that i want to be able to configure one of two ways. Either 1) each webpart can configure the property individually or 2) the user can configure the webparts so that the property is set on a page basis...i.e. if you set the property of one all webparts on the page get set.

I have been thinking about how to do this but am a bit stumped....looking for some guidance from the gurus out there.

TIA

share|improve this question

1 Answer 1

up vote 1 down vote accepted

From a Web Part you can reach other Web Parts in the same zone at least, WebPart.Zone Property.
Then you can set the property on all in the same zone, for example like this:

if (Zone == null) return;
Zone.WebParts.Cast<WebPart>().
  Where(webPart => webPart is MyWebPart).ToList().
  ForEach(webPart => ((MyWebPart)webPart).MyProperty = "Hello, world!");

Update:
You can also use Web Parts Connections to connect the Web Parts together. Although I personally find this a bit cumbersome.

Another solution is to implement updating of properties through querystring/request parameters.

share|improve this answer

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.