如何在视图中存储值并将其传递给控制器​​并从另一个视图再次使用它 [英] How Can I Store Value In A View And Pass It To Controller And Used It Again By Another View

查看:99
本文介绍了如何在视图中存储值并将其传递给控制器​​并从另一个视图再次使用它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个与一个控制器关联的视图。我可以在第一个视图中存储值并将其传递给控制器​​并由另一个视图再次使用

在mvc5 rozer文件中

there is 2 view associated with one controler .how can i store value in first view and pass it to controller and used it again by another view
in mvc5 rozer file

推荐答案

将数据存储在表单字段中(如果您不需要显示它们,则隐藏)并确保它们包含在提交给其他控制器的表单中。或者,如果客户端未更改数据,请使用服务器端机制来记住Session或TempData等数据。
Store the data in form fields (hidden if you don't need them to be displayed) and ensure they are included in the form submission to the other controller. Or if the data is unchanged by the client use a server-side mechanism to remember the data like the Session or TempData.


转到会话 [ ^ ]变量。



将值存入从第一个值开始的会话,你可以从任何地方获得它的价值。



-KR
Go for a Session[^] variable.

Store the value into the session from the first value and you can get the value from it from anywhere.

-KR


这篇关于如何在视图中存储值并将其传递给控制器​​并从另一个视图再次使用它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆