On my homepage, I am attempting to incorporate links that will render partial views - revealing information from the database when clicked. I want the link to be replaced by text on the same page. Despite following a tutorial, I am facing challenges in getting it to work within my project. Below is the code snippets I have:
The Home/Index view snippet:
<div id="NeZaman">
@Ajax.ActionLink("Ne Zaman Gelcekmiş?", "NeZaman", new AjaxOptions {
UpdateTargetId="NeZaman",
InsertionMode = InsertionMode.Replace,
HttpMethod="GET" })
</div>
The HomeController snippet:
private CaglaContext db = new CaglaContext();
public PartialViewResult NeZaman()
{
var neZaman = db.Caglas.Where(c => c.Id == 1).Select(c => c.NeZamanGelcek).FirstOrDefault();
return PartialView("_NeZaman", neZaman);
}
The partial view (_NeZaman.cshtml) snippet:
@model caglageldimi.Models.Cagla
<p>
@Model.NeZamanGelcek
</p>
The Model (Cagla.cs) snippet:
public class Cagla
{
public int Id { get; set; }
public bool GeldiMi { get; set; }
public string NeZamanGelcek { get; set; }
public string Nerdeymis { get; set; }
}
Currently, I am passing a value for neZaman which the partial view is expected to utilize, but how exactly?