Getting route data from partial route in a webform template
Vote:
I have configured a partial route in a website which is using web form templates.
I have followed the tutorial on partial routing and am able to register a partial route which correctly loads my aspx template when the route is matched.
I dont know the best way to access the custom route data from within the web form template.
Following the example in the SDK, if I where to create a webforms template to display a "NewsContent" item, the code behind I would look like this.
public partial class NewsContentTemplate : EPiServer.SimplePage, IRenderTemplate<NewsContent>
{
protected void Page_Load(object sender, EventArgs e)
{
// This is how i am getting the route data
var data = ((NewsContent)Request.RequestContext.RouteData.DataTokens["routedData"]);
}
}
The code for accessing the route data works but is this correct / the best way? If this was a page, I would inherit TemplatePage<T> which gives typed access to the model, however I cannot do that here as NewsContent is not a page in the CMS.
I have configured a partial route in a website which is using web form templates.
I have followed the tutorial on partial routing and am able to register a partial route which correctly loads my aspx template when the route is matched.
http://sdkbeta.episerver.com/SDK-html-Container/?path=/SdkDocuments/CMS/7/Knowledge%20Base/Developer%20Guide/Partial%20Routing/News%20partial%20routing%20example.htm&vppRoot=/SdkDocuments//CMS/7/Knowledge%20Base/Developer%20Guide/
I dont know the best way to access the custom route data from within the web form template.
Following the example in the SDK, if I where to create a webforms template to display a "NewsContent" item, the code behind I would look like this.
The code for accessing the route data works but is this correct / the best way? If this was a page, I would inherit TemplatePage<T> which gives typed access to the model, however I cannot do that here as NewsContent is not a page in the CMS.
Adam