I'm rewriting a Web Forms application as an exercise to learn some MVC skills.
I have a number of LinkButtons on the original application which postback and raise a serverside event that rebinds data to a datagrid.
E.g.
Event handlers:
protected void lbtnOffset0_Click(object sender, EventArgs e)
{
Session["Offset"] = 0;
DataBind(); //this rebinds the data using the above argument
}
protected void lbtnOffset1_Click(object sender, EventArgs e)
{
Session["Offset"] = lbtnOffset1.Text;
DataBind(); //this rebinds the data using the above argument
}
What I currently have in MVC is this:
<%= Html.ActionLink("CurrentYr", "Index", 0)%>
<%= Html.ActionLink("1", "Index", 1)%>
and
public ActionResult Index()
{
return View(MietController.GetMietByYearOffset(0);
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Index(int? offset)
{
int offsetValue = offset ?? 0;
return View(MietController.GetMietByYearOffset(offsetValue);
}
As the ActionLink renders an tag it doesn't postback so my overloaded Index() method isn't called. What are my options for doing this in MVC?