zoukankan      html  css  js  c++  java
  • Mvc4学习笔记一(Ajax.ActionLink)

    <style type="text/css">
        #left {width:200px; min-height:500px;border:1px solid #ccc;float:left;}
        #right { width:740px;min-height:500px;border:1px solid #ccc;float:left;margin-left:10px;}
    </style>
    <div id="left">
        <ul>
            <li>@Ajax.ActionLink("news title a", "Contents",new{id=1}, new AjaxOptions {HttpMethod="Post",InsertionMode= InsertionMode.Replace, UpdateTargetId="news_content" })</li>
            <li>@Ajax.ActionLink("news title b", "Contents",new{id=2}, new AjaxOptions {HttpMethod="Post",InsertionMode= InsertionMode.Replace, UpdateTargetId="news_content" })</li>
        </ul>
    </div>
    <div id="right">
        <div id="news_content"></div>
    </div>
    View Code
            [HttpPost]
            public ActionResult Contents(int? id)
            {
                IList<string> list1 = new List<string>
                {
                    "a news 1 title",
                    "a news 2 title",
                    "a news 3 title",
                    "a news 4 title",
                    "a news 5 title"
                };
                IList<string> list2 = new List<string>
                {
                    "b news 1 title",
                    "b news 2 title",
                    "b news 3 title",
                    "b news 4 title",
                    "b news 5 title",
                    "b news 6 title",
                    "b news 7 title"
                };
                var model = list1;
                if (id != 1)
                {
                    model = list2;
                }
               
                return PartialView(model);
            }
    Action

    主意需要引用jquery.unobtrusive-ajax.min.js文件

  • 相关阅读:
    ElasticSearch学习记录
    用java代码手动控制kafkaconsumer偏移量
    kafka0.9.0及0.10.0配置属性
    kafka常用命令
    kafka消费者客户端(0.9.0.1API)
    kafka入门教程链接
    编程内功
    bzoj3145:[Feyat cup 1.5]Str
    3 SpringBoot与微服务
    2 微服务存在的问题和解决方案
  • 原文地址:https://www.cnblogs.com/aweifly/p/3406239.html
Copyright © 2011-2022 走看看