Mvc-ajax-jquery Sub-page

Source: Internet
Author: User

"1"

Controller

<pre class= "CSharp" name= "code" >using system;using system.collections.generic;using System.data.entity.infrastructure;using system.linq;using system.web;using system.web.mvc;using System.web.script.serialization;namespace mvctest.controllers{public class Testcontroller:controller {sal        Esentities db = new SalesEntities (); Public ActionResult Index () {//display data var Query3 = (from a in db. T_user Select a). (r = r.id).                        Take (20);         Return View (Query3);  }//ajax the requested data (for paging) public jsonresult Paging (int pageIndex)//user passes a current page number over {var query = (from a In Db. T_user//query data based on the current page where a.ID > PageIndex * 5 Select a). Take (5)).            ToList ();    Jsonresult json = new Jsonresult (); Json.  Jsonrequestbehavior = Jsonrequestbehavior.allowget; Allows HTTP GET request JSON from the client.      Data = new         {result = query};  return JSON; Returns a JSON data}//--------------------------------------------------------------//--------------------------------        ------Increase [HttpGet] public ActionResult Add () {return View (); } [HttpPost] public actionresult Add (T_user u) {db. Entry (U).            state = System.Data.EntityState.Added; Db.            SaveChanges ();        Return redirecttoaction ("Index");            }//--------------------------------------Delete [httpget] public actionresult Del (int Id) { T_user u = db.            T_user.singleordefault (r = r.id = = Id);        return View (U); } [HttpPost] public actionresult Del (T_user u) {t_user UU = db.            T_user.singleordefault (r = r.id = = u.id); Db. Entry (UU).            state = System.Data.EntityState.Deleted; Db.            SaveChanges (); Return RedIrecttoaction ("Index"); }//--------------------------------------change public actionresult Edit (int Id) {t_user U = d            B.t_user.singleordefault (r = r.id = = Id);        return View (); } [HttpPost] public actionresult Edit (T_user u) {db. Entry (U).            state = System.Data.EntityState.Modified; Db.            SaveChanges ();        Return redirecttoaction ("Index"); }}}

Index view

@model ienumerable<mvctest.t_user>@{Layout = null;} <! DOCTYPE html>


Mvc-ajax-jquery Sub-page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.