Using LoginStatus as a partial view - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Using LoginStatus as a partial view

  • 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
     
    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
     
  • Thanks for the information.  That does make sense, I guess I was hoping I was missing something trivial.