asp.net mvc ViewBag常用操作
1.视图获取json类型数据
var str = '@(ViewBag.loginInfoList)';
if ($.trim(str).length>0) {
re = new RegExp(""", "g"); //定义正则表达式,g标识全部替换 将\转译为",成为正确的json格式数据
var newstr = str.replace(re, '"');
re = new RegExp("{", "g"); //定义正则表达式,g标识全部替换
newstr = newstr.replace(re, "[{");
re = new RegExp("}", "g"); //定义正则表达式,g标识全部替换
newstr = newstr.replace(re, "}]"); var jsonData = $.parseJSON(newstr); //将字符串转换为json格式
var PassageWayList = jsonData[0].id + "-" + jsonData[0].Brand + ",";
}
/// <summary>
/// 摄像头预览
/// </summary>
/// <returns></returns>
public ActionResult CameraView(string id)
{
var bllArea = new CameraArea();
modelArea = bllArea.GetModel();
var josnArry = new JsonResult { Data = modelArea, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
ViewBag.loginInfoList = josnArry.Data.ToJSON(); return View();
}
asp.net mvc ViewBag常用操作的更多相关文章
- ASP.NET MVC 3 常用
http://blog.csdn.net/churujianghu/article/details/7297358 1.ASP.NET MVC 3 如何去除默认验证 这个默认验证是在web.confi ...
- Asp .Net MVC中常用过滤属性类
/// <summary> /// /// </summary> public class AjaxOnlyAttribute : ActionFilterAttribute ...
- Asp.net MVC使用EasyNetQ操作RabbitMQ
Demo下载地址:https://download.csdn.net/download/u010312811/11259742 .Net下操作RabbitMQ最常用的SDK是RabbitMQ.Clie ...
- asp.net mvc access数据库操作
连接access数据库其实也简单,只要按照mvc的模式来就可以,遵循c v约定就可以 既然渲染试图是强类型,那么取得的数据就转换成强类型,其他一切和asp.net操作一样 DB mydb = new ...
- ASP.NET MVC中常用的ActionResult类型
常见的ActionResult 1.ViewResult 表示一个视图结果,它根据视图模板产生应答内容.对应得Controller方法为View. 2.PartialViewResult 表示一个部分 ...
- .Net Mvc学习——ASP.NET MVC中常用的ActionResult类型
一.定义 MVC中ActionResult是Action的返回结果.ActionResult 有多个派生类,每个子类功能均不同,并不是所有的子类都需要返回视图View,有些直接返回流,有些返回字符串等 ...
- ASP.NET MVC ViewBag/ViewData/TempData区别
ViewBag/ViewData public dynamic ViewBag { get; } public ViewDataDictionary ViewData { get; set; } Vi ...
- ASP.NET MVC 的常用的HTML辅助方法笔记
Html.BeginForm() 输出<form>标签Html.EndForm() 输出</form>标签Html.Label() 输出<label>标签Html. ...
- asp.net mvc webconfig配置文件操作
读取web.config数据,可以不用编译.如发布后,非常有用web.config文件<configuration> <appSettings> <add key=&qu ...
随机推荐
- JMETER 审批任务实战
业务场景 我们需要对流程任务进行审批,这个和流程发起是不一样的,因为在流程发起时,只需要用户登录后,指定固定的流程方案和数据就可以发起流程了. 流程任务是需要获取任务ID再做任务审批的. 实现思路 1 ...
- Redis缓存实战教程
目录 Redis缓存 使用缓存Redis解决首页并发问题 1.缓存使用的简单设计 2.Redis的整合步骤 A 将Redis整合到项目中(Redis+Spring) B 设计一个数据存储策越 3.Re ...
- Shel脚本-初步入门之《03》
Shel脚本-初步入门-Shell 脚本在 Linux 运维工作中的地位 3.Shell 脚本在 Linux 运维工作中的地位 Shell 脚本语言很适合用于处理纯文本类型的数据,而 Linux 系统 ...
- LeetCode 100. Same Tree相同的树 (C++)
题目: Given two binary trees, write a function to check if they are the same or not. Two binary trees ...
- Regular Forestation CodeForces - 1252F(树同构)
Regular Forestation \[ Time Limit: 1000 ms\quad Memory Limit: 262144 kB \] 题意 给出一个节点为 \(n\) 的树,问删掉树上 ...
- 2.GO-可变参数函数、匿名函数和函数变量
2.1.可变参数函数 可变参数指参数的个数可以是任意个 可变参数必须在参数列表最后的位置,在参数名和类型之间添加三个点表示可变参数函数 声明函数时,在函数体把可变参数当作切片使用即可 package ...
- linux帮助命令使用
一. help使用 查看ls命令的帮助信息 ls --help # 查看全部 ls --help | less # 分页查看, q退出 二. man手册 同一命令存在于多个章 ...
- [LeetCode] 187. Repeated DNA Sequences 求重复的DNA序列
All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACG ...
- [LeetCode] 148. Sort List 链表排序
Sort a linked list in O(n log n) time using constant space complexity. Example 1: Input: 4->2-> ...
- [LeetCode] 95. Unique Binary Search Trees II 独一无二的二叉搜索树之二
Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1 ...