I have a list of objects and I want to be able to select a specific one and view a different view with specific information regarding the object
e.g.
A list of bikes, but you want to see specific information regarding a bike, if it is broken or whatever.
How do I go from one view to another, using a link (could be actionlink) and still using current layout using a controller and method. I have semi solved the issue, but when I open the link it opens a blank page with what I have, no navigation bar or anything.
Any ideas?
This is what i have in my current vieiw: <td>@Html.ActionLink("LinkText", "ControllerName", "MethodName", new { id = Something }, null)</td>
Edit: I have correct controller, method name and ID in my view, this is just an example
The ActionLink i have right now, is the only way i know of, to get a Call to action button / Linktext, it should open in a new page but within the same template.
If I understand you correctly, you have some information in a database (about Bikes) that you want to load dynamically to a page using its id. If so, this is how am doing it for real estate listings. The way to do it is different between versions 7 and 8, so I am including code for both.
Side Note..... you may have to create a custom route.
******************
*** UMBRACO 7 ***
******************
***** The Controller *****
using System.Globalization;
using System.Web.Mvc;
using Umbraco.Core.Models;
using Umbraco.Web;
using Umbraco.Web.Models;
namespace zbdpm.Controllers
{
//[OutputCache(NoStore = true, Duration = 0)]
public class PropertyController : Umbraco.Web.Mvc.SurfaceController
{
public PropertyController()
: this(UmbracoContext.Current)
{
}
public PropertyController(UmbracoContext umbracoContext)
: base(umbracoContext)
{
}
private RenderModel CreateUmbracoModel()
{
//use and existing node
umbraco.NodeFactory.Node node = umbraco.uQuery.GetNode(-1).Children[0];
IPublishedContent currentNode = Umbraco.TypedContent(node.Id);
var model = new RenderModel(currentNode, CultureInfo.CurrentUICulture);
//add an umbraco data token so the umbraco view engine executes
RouteData.DataTokens["umbraco"] = model;
return model;
}
public ActionResult Index(string propertyID)
{
PropertyDetails p = new PropertyDetails();
p = z.zpmAPI(propertyID).jsonToEntity<PropertyDetails>();
if (p._Property.PropertyID == null)
{
return View("/Views/Partials/Property/real-estate-not-found.cshtml", CreateUmbracoModel());
}
else
{
ViewBag.PropertyDetails = p;//using viewbag to pass data through the umbraco model
return View("/Views/Partials/Property/real-estate.cshtml", CreateUmbracoModel());
}
}
public ActionResult PropertyDetails(PropertyDetails p)
{
return PartialView("~/Views/Partials/Property/_zProperty.cshtml", p);
}
}
}
***** real-estate.cshtml *****
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
<div class="container-fluid">
<div class="container">
@Html.Action("PropertyDetails", "Property", (dbzBestPM.Models.PropertyDetails)ViewBag.PropertyDetails)
</div>
</div>
***** zProperty.cshtml *****
@model dbzBestPM.Models.PropertyDetails
<div id="Section-PropertyDetails">
<div class="row">
<div class="col-xs-12 col-sm-8 col-md-8 col-lg-8 col-xl-8">
<h1>@Model._Property.StreetAddress.Trim() @Model._Property.City.Trim(), @Model._Property.State.Trim() </h1>
</div>
</div>
******* PAGE HTML HERE *****
</div>
How to get to another view with a link and MVC
Hello,
I have a list of objects and I want to be able to select a specific one and view a different view with specific information regarding the object
e.g. A list of bikes, but you want to see specific information regarding a bike, if it is broken or whatever.
How do I go from one view to another, using a link (could be actionlink) and still using current layout using a controller and method. I have semi solved the issue, but when I open the link it opens a blank page with what I have, no navigation bar or anything.
Any ideas?
This is what i have in my current vieiw:
<td>@Html.ActionLink("LinkText", "ControllerName", "MethodName", new { id = Something }, null)</td>
Edit: I have correct controller, method name and ID in my view, this is just an example
This is my result:
Anyone got any ideas, i am running low on google search options to fix this
When you click the link, is it supposed to go to a new page or load a div with a partial view on the current one?
The ActionLink i have right now, is the only way i know of, to get a Call to action button / Linktext, it should open in a new page but within the same template.
If I understand you correctly, you have some information in a database (about Bikes) that you want to load dynamically to a page using its id. If so, this is how am doing it for real estate listings. The way to do it is different between versions 7 and 8, so I am including code for both.
Side Note..... you may have to create a custom route.
is working on a reply...