Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
I have created a AccountSurfaceController which has a ActionMethod to render the login modal.
AccountSurfaceController
This modal contains a link to the register content node.
How can I get the url to my register page in my partial view of the surface controller?
I can't access the current page like @CurrentPage.
@CurrentPage
My partial view:
@model Prosec.Models.AccountLoginViewModel @using Prosec.Controllers; <div class="modal fade" id="modal-account-login" tabindex="-1" role="dialog" aria-hidden="true"> <div class="modal-dialog modal-sm"> <div class="modal-content"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <div class="modal-header"> <h4 class="modal-title">Welkom terug</h4> </div> @using (Html.BeginUmbracoForm<AccountSurfaceController>("MemberLogin", "AccountSurface", new { @id = "formLogin", @class = "form-horizontal", role = "form" })) { @Html.AntiForgeryToken() <div class="modal-body"> <div class="validations-output"></div> <div class="form-group"> <div class="col-sm-12"> @Html.TextBoxFor(m => m.Username, new { @class = "form-control", placeholder = "Gebruikersnaam..." }) </div> </div> <div class="form-group"> <div class="col-sm-12"> @Html.PasswordFor(m => m.Password, new { @class = "form-control", placeholder = "Wachtwoord..." }) </div> </div> <div class="form-group"> <div class="col-sm-6"> <div class="form-checkbox"> @Html.CheckBoxFor(m => m.RememberMe, new { @class = "" }) <label for="RememberMe">Mij onthouden?</label> </div> </div> </div> <button type="submit" class="btn btn-primary btn-lg"><span>Aanmelden</span></button> </div> <div class="modal-links"> <ul> <li><a class="account-forgot-pwd-btn" href="#"><i class="fa fa-caret-right"></i>Wachtwoord vergeten?</a></li> <li> // Here I need to get the url of the register page content node...................... <a href="#"><i class="fa fa-caret-right"></i>Account registreren?</a> </li> </ul> </div> } </div> </div> </div>
/Michael
Add a property to your AccountLoginViewModel named 'CurrentPage' of type IPublishedContent and pass it on from the SurfaceController.
Then you can access it from Model.CurrentPage in your partial view.
Or you only need the URL to the Register page then add a string property on your viewmodel an populate it with the CurrentPage.Url value from your AccountSurfaceController before you return the partialview.
CurrentPage.Url
Hi Michaël,
You can also do
@inherits UmbracoViewPage<Prosec.Models.AccountLoginViewModel>
instead of
@model Prosec.Models.AccountLoginViewModel
Then you will have access to the Umbraco Helper in your view.
You can use this to get the current IPublished content item :
@Umbraco.AssignedContentItem
Dave
I had no idea that that you could do that, thats great. I´m gonna start using that one! :)
Hi dennis,
You can read the article I wrote for the Christmas calendar. I explain the differences between the template types in Umbraco : http://24days.in/umbraco/2015/strongly-typed-vs-dynamic-content-access/
And also difference between dynamic and strongly typed content access.
Awsome, thank you! I´ll defenetly look at it! :)
Nice one didn't know about that!
Thanks for this solution
Don't forget to mark the topic as solved. So others can find the solution as well.
I know, I was first impleting it in my solution and test it.
Again thanks for the intel!
Great post Dave (http://24days.in/umbraco/2015/strongly-typed-vs-dynamic-content-access/)!
Perfect saturday read. :)
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
CurrentPage is not available in a surface controller partial view
Hi,
I have created a
AccountSurfaceController
which has a ActionMethod to render the login modal.This modal contains a link to the register content node.
How can I get the url to my register page in my partial view of the surface controller?
I can't access the current page like
@CurrentPage
.My partial view:
/Michael
Add a property to your AccountLoginViewModel named 'CurrentPage' of type IPublishedContent and pass it on from the SurfaceController.
Then you can access it from Model.CurrentPage in your partial view.
Or you only need the URL to the Register page then add a string property on your viewmodel an populate it with the
CurrentPage.Url
value from yourAccountSurfaceController
before you return the partialview.Hi Michaël,
You can also do
instead of
Then you will have access to the Umbraco Helper in your view.
You can use this to get the current IPublished content item :
Dave
I had no idea that that you could do that, thats great. I´m gonna start using that one! :)
Hi dennis,
You can read the article I wrote for the Christmas calendar. I explain the differences between the template types in Umbraco : http://24days.in/umbraco/2015/strongly-typed-vs-dynamic-content-access/
And also difference between dynamic and strongly typed content access.
Dave
Awsome, thank you! I´ll defenetly look at it! :)
Nice one didn't know about that!
Thanks for this solution
/Michael
Hi Michaël,
Don't forget to mark the topic as solved. So others can find the solution as well.
Dave
I know, I was first impleting it in my solution and test it.
Again thanks for the intel!
/Michael
Great post Dave (http://24days.in/umbraco/2015/strongly-typed-vs-dynamic-content-access/)!
Perfect saturday read. :)
is working on a reply...