0

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

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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