开发者

How to use ASP.Net -- Html.ActionLink()

Okay, I'm pretty new to ASP.Net / MVC 2. Can anyone explain how to use the Html.ActionLink thing? I understand that the first parame开发者_开发百科ter is the displayed text, but for the second one, what is the action name??


User action in the asp.net MVC framework is based around Controllers and Actions that enable you to create pages (or links) to specific sections.

For example you might want a page to edit a Product so you have a Product Controller with an Edit Action. You can then create a Html ActionLink that will direct the user to this page.

In summary the 'action' will be the ActionResult method you want to direct your user to.

<%: Html.ActionLink("Edit Product", "Edit", "Product") %>

public class ProductController : Controller
{
    public ActionResult Index() // Index is your action name
    {
    }

    public ActionResult Edit(int id) // Edit your product
    {
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜