Using LoginStatus as a partial view
I am trying to load the Login Status widget into another view.
I can get the default template to show up, but would like to know if it is possible to pass initialization properties as well.
If I put @Html.Action("Index", "LoginStatus") into my view I can see that LoginStatus.LoginButton.cshtml is loading markup, but I get no functionality due to not setting the loginpageid and other properties.
I tried this type of format without any luck:
@Html.Action(
"Index"
,
"LoginStatus"
,
new
TemplateName =
"LoginName"
, LoginPageId = <guid> )
The view still loads the default template and no exceptions show up, but still no functionality if I click to login.
Hello,
What you are trying to achieve is not possible because the TemplateName and LoginPageId are properties of the Controller and Model respectively. The PartialView method can only pass route data to the action and cannot access properties of the controller or model.
You can try rendering the view to string in the controller (http://stackoverflow.com/questions/483091/render-a-view-as-a-string) and displaying it as raw html in the view. This way you will be able to set the properties of the controller as well as create a model and set its properties.
Please note that in Sitefinity's context you will need to use the SitefinityViewEngine class and call its FindView method instead of calling the FindView method on the ViewEngines collection.
Please also note that this approach renders only the view and any other necessary scripts will need to be added manually.
Regards,
Velizar Bishurov
Telerik
Thanks for the information. That does make sense, I guess I was hoping I was missing something trivial.