Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net MVC链接按钮均价_Asp.net_Asp.net Mvc - Fatal编程技术网

Asp.net MVC链接按钮均价

Asp.net MVC链接按钮均价,asp.net,asp.net-mvc,Asp.net,Asp.net Mvc,我正在重写一个Web表单应用程序,作为学习一些MVC技能的练习 我在原始应用程序上有许多linkbutton,它们回发并引发服务器端事件,将数据重新绑定到datagrid 例如。 事件处理程序: protected void lbtnOffset0_Click(object sender, EventArgs e) { Session["Offset"] = 0; DataBind(); //this rebinds the data using the above argum

我正在重写一个Web表单应用程序,作为学习一些MVC技能的练习

我在原始应用程序上有许多linkbutton,它们回发并引发服务器端事件,将数据重新绑定到datagrid

例如。

事件处理程序:

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
}
我目前在MVC中拥有的是:

     <%= Html.ActionLink("CurrentYr", "Index", 0)%>
     <%= Html.ActionLink("1", "Index", 1)%>

ActionLink呈现标记时不会回发,因此不会调用重载的Index()方法。在MVC中执行此操作的选项有哪些?

尝试将您的操作链接更改为:

 <%= Html.ActionLink("CurrentYr", "Index", new { offset = 0 } )%> 
 <%= Html.ActionLink("1", "Index", 1, new { offset = 1 } )%> 

并添加HttpVerbs。进入第二个索引操作

超链接作为GET请求发送。只要您的操作接受它们,并且确保将正确的参数添加到命令行,就可以了


您可能还想考虑创建这些Ajax Actudio链接,而不是使用POST,但需要指定新内容加载到何处。操作可能还需要更改,以便在通过AJAX请求时返回部分视图,这样您就不会返回整个页面,而只返回更新的部分。

尝试将操作链接更改为:

 <%= Html.ActionLink("CurrentYr", "Index", new { offset = 0 } )%> 
 <%= Html.ActionLink("1", "Index", 1, new { offset = 1 } )%> 

并添加HttpVerbs。进入第二个索引操作

超链接作为GET请求发送。只要您的操作接受它们,并且确保将正确的参数添加到命令行,就可以了


您可能还想考虑创建这些Ajax Actudio链接,而不是使用POST,但需要指定新内容加载到何处。该操作可能还需要更改,以便在通过AJAX请求时返回部分视图,这样您就不会返回整个页面,而只返回更新后的部分。

您似乎错过了“,”介于1和new之间。@Nitin:谢谢。我已经修正了打字错误。这很有效,谢谢。我将查看AJAX操作链接。似乎您错过了“,”介于1和新之间。@Nitin:谢谢。我已经修正了打字错误。这很有效,谢谢。我将研究AJAX操作链接。