zoukankan      html  css  js  c++  java
  • Html.ActionLink("linkText","actionName")

    Html.ActionLink("linkText","actionName")

    该重载的第一个参数是该链接要显示的文字,第二个参数是对应的控制器的方法,

    默认控制器为当前页面的控制器,如果当前页面的控制器为Products,则 Html.ActionLink("detail","Detail")

    则会生成 <a href="http://m.cnblogs.com/Products/Detail" target="_blank" rel="nofollow">

    二 Html.ActionLink("linkText","actionName","controlName")

    该重载比第一个重载多了一个参数,他指定了控制器的名称,

    如Html.ActionLink("detail","Detail","Products")则会生成

    <a href="http://m.cnblogs.com/133831/Products/Detail" target="_blank" rel="nofollow">

    三 Html.ActionLik("linkText","actionName",routeValues)

    routeValue可以向action传递参数,如Html.ActionLink("detail","Detail",new { id=1})

    会生成 <a href="http://m.cnblogs.com/133831/Products/Detail/1" target="_blank" rel="nofollow">

    此处假设当前的控制器是Products.

    四 Html.ActionLink("linkText","actionName",routeValues,htmlAttributes)

    htmlAttribute可以设置<a>标签的属性,

    如 Html.ActionLink("detail","Detail",new{id=1},new{ target="_blank"})

    会生成 <a href="http://m.cnblogs.com/133831/Products/Detail/1" target="_blank" rel="nofollow">

    需要主要的是如果写成 new{ target="_blank",class="className"}则会报错,

    因为class是关键字,此处应该写成 @class="className"。

    五 Html.ActionLink("linkText","actionName","controlName",routeValues,htmlAttributes)

    该重载包含了上面提到的所有参数类型

  • 相关阅读:
    poj 3071 Football (概率dp)
    CF1408G Clusterization Counting
    2-sat
    线段树优化建图
    SP5971 LCMSUM
    [NOI2020]命运
    SP19149 INS14H
    Atcoder ARC-068
    CF908G New Year and Original Order
    (四)、Fiddler打断点
  • 原文地址:https://www.cnblogs.com/520cc/p/3216443.html
Copyright © 2011-2022 走看看