I think I may have found a bug in WebMatrix\'s PageData, but I am not sure. It concerns how to pass data from a partial page back to a calling page.
In the WebMatrix
You layout page is overwriting the value passed to it form the partial page. To pass data from the partial page to the layout page use a different indexer.
Partial page
@{
PageData["test"] = "value form partial";
}
Layout page
@{
PageData["anothertest"] = "value from layout";
}
test value = @PageData["test"]
anothertest value = @PageData["anothertest"]
If you want to have a default value in the layout page that is displayed if your partial page doesn't set the value then you can do the following
Layout page
@{
var test = PageData["test"] ?? "Layout default value";
}
test value = @test
Partial page
@{
PageData["test"] = "partial page value";
}
If your partial page does not set PageData["test"] then "Layout default value" will be used