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-7
            string 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进行模糊查询的时候,直接使用即可。


<span style="font-size:24px;"><script>
        @*模糊查询的js——刘少锋——2016-8-3 15:55:29*@
            function doSearch(value, name) {

                var ExamID = $('#ExamID').val();
                var ExamPlaceID = $('#ExamPlaceID').val();
                var StartDate = $('#StartDate').val();
                var StartTime = $('#StartTime').val();

                $('#Chapter1').datagrid({
                    url: '/Monitore/FuzzyQueryStudentInfo?strLike=' + value + "&ExamID=" + ExamID + "&ExamPlaceID=" + ExamPlaceID + "&StartDate=" + StartDate + "&StartTime=" + StartTime
                });
                $("#Chapter1").datagrid("reload");//重新加载表信息datagrid
            }
        </script></span>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值