Using GetItemFromUrl in SimpleView
Hi,
I'm trying to get the current item from the url in a SimpleView control created with Thunder;
First time I enter a page the item can't be resolved (null), if I F5 the page the item is resolved.
I've tried using other events but no success, anybody have an idea?
protected
override
void
InitializeControls(GenericContainer container)
SetSingleItem();
Label messageLabel =
this
.MessageLabel;
if
(currentProject !=
null
)
messageLabel.Text = currentProject.GetValue<Lstring>(
"Title"
);
else
messageLabel.Text =
"Hello, World!"
;
protected
void
SetSingleItem()
var urlParameters =
this
.GetUrlParameters();
if
(urlParameters !=
null
&& urlParameters.Length != 0)
var redirectUrl =
""
;
DynamicModuleManager manager =
new
DynamicModuleManager();
Type projectType = TypeResolutionService.ResolveType(
"Telerik.Sitefinity.DynamicTypes.Model.Projects.Project"
);
var item = manager.Provider.GetItemFromUrl(projectType,
this
.GetUrlParameterString(
true
),
out
redirectUrl)
as
DynamicContent;
if
(item !=
null
&& item.GetType() == projectType)
currentProject = item;