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文件

  • 相关阅读:
    Python实现网络多人聊天室
    C实现string字符串
    C getchar()
    C++ 数组遍历的两种方式
    Java 发红包
    Java递归实现阶乘
    Go defer语句
    bash shell——sum
    C——letterCounter
    数据结构——链队列(linked queue)
  • 原文地址:https://www.cnblogs.com/aweifly/p/3406239.html
Copyright © 2011-2022 走看看