1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Web; 5 using System.Web.Mvc; MVCCrud.Areas.JqGridDemo.Controllers 8 { QueryStringController : Controller 10 { ActionResult Index() 13 { 14 return View(); 15 } GetParamsFromToView(string EmployeeID,string EmployeeName) 18 { ].ToString(); ].ToString(); 21 } 22 } 23 }
View:
1 @{ 2 Layout = null; 3 } Index () { () { ; 17 }); 18 }); QueryString向Controller传递值
result:
3.2 AJax
controller:
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Web; 5 using System.Web.Mvc; MVCCrud.Areas.JqGridDemo.Controllers 8 { AjaxDataController : Controller 10 { ActionResult Index() 13 { 14 return View(); 15 } GetParamsFromAjax(string EmployeeID, string EmployeeName) 19 { 20 21 } 22 } 23 }
View:
1 @{ 2 Layout = null; 3 } Index () { () { 15 $.ajax({ , , }, (message) { ); 21 } 22 }); 23 }) 24 }) Ajax传递参数
或者
1 @{ 2 Layout = null; 3 } Index () { () { 15 $.ajax({ , , (message) { ); 21 } 22 }); 23 }) 24 }) Ajax传递参数
result:
3.3 Form传递
controller:
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Web; 5 using System.Web.Mvc; MVCCrud.Areas.JqGridDemo.Controllers 8 { FormTransferDataController : Controller 10 { ActionResult Index() 13 { 14 return View(); 15 } GetParamsFromForm(string EmployeeID, string EmployeeName) 19 { 20 21 } 22 } 23 }
View:
1 @{ 2 Layout = null; 3 } Index员工ID:员工姓名:
result:
3.4 FormCollection
controller:
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Web; 5 using System.Web.Mvc; MVCCrud.Areas.JqGridDemo.Controllers 8 { FormCollectionTransferDataController : Controller 10 { ActionResult Index() 13 { 14 return View(); 15 } GetParamsFromFormCollection(FormCollection fc) 19 { ].ToString(); ].ToString(); 22 } 23 } 24 }
view: