zoukankan      html  css  js  c++  java
  • MVC中的Html.ActionLink

    以下使用参数文字说明:

    1. linkText:生成的链接所显示的文字         类型:string
    2. actionName:对应控制器的方法          类型:string
    3. routeValues:向对应的action传递的参数      类型:object 或 RouteValueDictionary
    4. controlName:指定控制器的名称           类型:string
    5. htmlAttributes:设置<a>标签的属性                   类型:object 或 IDictionary
    6. protocol:指定访问协议如:http等         类型:string
    7. hostName:指定访问域名             类型:string
    8. fragment:指定访问锚点              类型:string

    重载一:Html.ActionLink("linkText","actionName")【默认当前页面控制器】

    调用:@Html.ActionLink("默认当前页面控制器", "About")

    生成效果:<a href="/Home/About">默认当前页面控制器</a>

    重载二:Html.ActionLink("linkText","actionName",routeValues)

    调用:

      routeValues Is object:

      @Html.ActionLink("默认当前页面控制器", "About", new { id = 1, type = "Dic" })

      routeValues Is RouteValueDictionary:

      @RouteValueDictionary Dictionary = new RouteValueDictionary();
      @Dictionary["id"] = 1;
      @Dictionary["type"] = "Dic";
      

      @Html.ActionLink("默认当前页面控制器", "About", Dictionary)

    生成效果:<a href="/Home/About?classid=1">默认当前页面控制器</a>

    重载三:Html.ActionLink("linkText","actionName","controlName")

    调用:@Html.ActionLink("默认当前页面控制器", "About", "Home")

    生成效果:<a href="/Home/About">默认当前页面控制器</a>

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

    调用:

      htmlAttributes Is object:

      @Html.ActionLink("首页", "Index", "Home", null, new { @class = "active", target = "_blank" })%>【注:由于class是保留关键字,所以一定要写成@class】

      htmlAttributes Is IDictionary:

      @IDictionary<string, object> AttrDictionary = new Dictionary<string, object>();

      @AttrDictionary["class"] = "active";

      @AttrDictionary["target"] = "_blank";

    生成效果:<a class="active" href="/" target="_blank">首页</a>

    重载五:Html.ActionLink("linkText","actionName","controlName","protocol","hostName","fragment",routeValues,htmlAttributes)

    调用:@Html.ActionLink("关于我们", "About", "Home", "http", "localhost", "top", null, null)

    生成效果:<a href="http://localhost:12120/Home/About#top">关于我们</a>

  • 相关阅读:
    配置webpack.config.js中的文件
    webpack-dev-server运行时报错
    vue 中的通过搜索框进行数据过滤的过程
    vue中的computed(计算属性)和watch(监听属性)的特点,以及深度监听
    关于vue-router 中参数传递的那些坑(params,query)
    treeSet比较功能
    练习:往HashSet中存储学生对象(姓名,年龄) 同姓名,同年龄视为一个人,不存
    LinkedList实现堆栈或者队列
    LInkedList特有方法演示
    ★★★ArrayList去除指定对象的重复元素
  • 原文地址:https://www.cnblogs.com/jack022/p/4785073.html
Copyright © 2011-2022 走看看