當前位置:
首頁 >
View和View的参数传递二
發布時間:2025/3/20
54
豆豆
生活随笔
收集整理的這篇文章主要介紹了
View和View的参数传递二
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
View和View的參數傳遞二
? ? ? ? ? 在做ITOO的時候,有一個需求,就是考生登錄情況的模糊查詢功能,用到了第一個頁面中的參數,但是,這里的模糊查詢事件是在第二個頁面中觸發的。
? ? ? ? ??解決辦法
? ? ? ? ??首先,第一個頁面在跳轉到第二個頁面的時候,進行參數的傳遞,把用到的參數傳遞給Controller,然后,使用ViewData從Controller返回到第二個頁面。
? ? ? ? ??第一個頁面
<span style="font-size:24px;"><script type="text/javascript">//在"操作"一列中添加超鏈接.-編輯考核項目function rowformater(value, row, index) {return '<a href="/Monitore/MonitoreDetails?ExamID=' + row.ExamID + '&ExamPlaceID=' + row.ExamPlaceID + '&StartDate=' + row.StartDate + '&StartTime=' + row.StartTime + '">詳情</a>'return;} </script></span>? ? ? ? ??Controller
<span style="font-size:24px;">public ActionResult MonitoreDetails(){//從監測界面拿到相關信息,查詢具體學生信息-趙寒-2016-5-7string ExamID = Request.QueryString["ExamID"];string ExamPlaceID = Request.QueryString["ExamPlaceID"];string StartDate = Request.QueryString["StartDate"];string StartTime = Request.QueryString["StartTime"];ViewData["ExamID"] = ExamID;ViewData["ExamPlaceID"] = ExamPlaceID; ViewData["StartDate"] = StartDate;ViewData["StartTime"] = StartTime;return View();}</span>? ? ? ? ??在第二頁面中,使用隱藏的控件來接收這些參數。
<span style="font-size:24px;"><input id="ExamID" value=@ViewData["ExamID"] hidden /><input id="ExamPlaceID" value=@ViewData["ExamPlaceID"] hidden /><input id="StartDate" value=@ViewData["StartDate"] hidden /><input id="StartTime" value=@ViewData["StartTime"] hidden /></span>? ? ? ? ??此時,這些參數就有了,使用js進行模糊查詢的時候,直接使用即可。
總結
以上是生活随笔為你收集整理的View和View的参数传递二的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: View和View的参数传递
- 下一篇: DES的加密解密