I have an episerver page with a contentarea. Each of the blocks that goes into the content area are quite data heavy, so i would like to share data from the page to the blocks in the content area. I know this is quite easy to achieve in MVC using the Html.PropertyFor helper. But what are my options in WebForms, while still maintaing on-page edit and support for rendersettings tags ?
Currently i have the following suggestions :
Do you have any other suggestions on how to achieve this ?
If the data is expensive to get from the data source, it's probably worth using cache like the ISyncronicedObjectCache
to store your expensive data. You could of course only use the HttpContext to store the expensive data during the request but if you have many users that will still result in a performance problem since every new request will require getting the data again.
Using EPiServers caching will also help if you later decide to load balance your solution
You can do the same in webforms. This is how you pass data with the property webcontrol, you can also do it code-behind if you want to do it in a more typed way:
<EPiServer:Property PropertyName="YourContentArea" runat="server">
<RenderSettings YourPropertyThatWillEndUpInRenderSettings="TheData" />
Then from your view's code-behind you can get the property by calling:
The few experiments i have done with that method, suggests that only string values can be passed that way is that correct ? i could of course serialize the data to json.
If you want to pass values arround in the UI they must be serialized, but technically you can pass anything in the RenderSettings dictionary. This is however not just a problem in webforms, you have the same issue in mvc.In this case you could pass the page id and then load it in the block. You have the current page object in the block, but it will be the startpage when the block is re-rendered when e.g. an editor changes anything.
This might be an XY problem, http://xyproblem.info/. What are you really trying to achieve here? Having blocks dependent on the page they're rendered on usually ends up with problems.