Using LoginStatus as a partial view

Posted by Community Admin on 05-Aug-2018 14:26

Using LoginStatus as a partial view

All Replies

Posted by Community Admin on 17-May-2016 00:00

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.

Posted by Community Admin on 20-May-2016 00:00

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

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 20-May-2016 00:00

Thanks for the information.  That does make sense, I guess I was hoping I was missing something trivial.  

This thread is closed