如何在mvc3中获取标签控件中Json的值 [英] How to take value of Json in label control in mvc3
本文介绍了如何在mvc3中获取标签控件中Json的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码是
my code is
string reg2 = @"^[0-9a-zA-Z/-]+$";
var expr1 = new Regex(reg2);
if (reg_no !="" && !expr1.IsMatch(reg_no))
{
return Json("Please Enter Correct Registration Number !", JsonRequestBehavior.AllowGet);
}
这里我希望返回Json值应该来自Label控件,我怎么做这个plz帮助我
here i want that return Json value should come in Label control , how cam i do this plz help me
推荐答案
;
var expr1 = 新正则表达式(reg2);
如果(reg_no!= &&!expr1.IsMatch(reg_no))
{
return Json( 请输入正确的注册号!,JsonRequestBehavior.AllowGet);
}
"; var expr1 = new Regex(reg2); if (reg_no !="" && !expr1.IsMatch(reg_no)) { return Json("Please Enter Correct Registration Number !", JsonRequestBehavior.AllowGet); }
这里我希望返回Json值应该来自Label控件,我怎么做这个plz帮助我
here i want that return Json value should come in Label control , how cam i do this plz help me
调用JS并使用Ajax Callback,它可以实现。
在下面的例子中,调用一个函数SelectCity,在这个函数中我们在控制器中调用一个返回字符串值的Action。我们这里也有一个回调函数,当它返回然后它转到回调函数并且我们在标签中设置值。
Call a JS and using Ajax Callback, it can be achieved.
In below example, Call a function SelectCity, in this function we call a Action in controller that returns string value. We have a callback function here also when return then it go to callback function and we set the value in label.
function SelectCity(id) {
var cityid =
( ' #' + id).val();
('#' + id).val();
这篇关于如何在mvc3中获取标签控件中Json的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文