从JQuery设置ViewData [英] Set ViewData From JQuery

查看:191
本文介绍了从JQuery设置ViewData的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1.如何通过jQuery设置ViewData或TempData值?
2.如何获取隐藏字段"值以在MVC 2中呈现视图.
像:

1. How can i set the ViewData or TempData value from jQuery ?
2. How can i get the Hidden Field Value to render the view in MVC 2.
like:

<input type ="hidden" id="hide" />




<%:这里如何获取隐藏字段数据? %>




<%:Here how can i get the hidden field data? %>

推荐答案



以下是您的问题的答案:

1.如何通过jQuery设置ViewData或TempData值?
您不能使用JQuery设置ViewData或TempData的值.但您可以将任何值作为Query或JSON格式传递.

2.如何获取隐藏字段"值以在MVC 2中呈现视图.
您可以使用javascript获取隐藏字段值.使用以下代码获取价值
Hi,

Following are the answers of your question:

1. How can i set the ViewData or TempData value from jQuery ?
You can not set the value of ViewData or TempData using JQuery. but you can pass the any value as Query or JSON format.

2. How can i get the Hidden Field Value to render the view in MVC 2.
You can get hidden field value using javascript. use following code to get value
<script lang="javascript">
function getHiddenValue()
{
   var hidenvalue =  documetn.getElemetById('hide').value;
   alert("Value in hidden field is : " + hidenvalue); 
}
</script>


这篇关于从JQuery设置ViewData的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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