![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
MVC
文章平均质量分 75
zhouranlovesmile
这个作者很懒,什么都没留下…
展开
-
MvcHtmlString解决MVC中从后台返回HTML代码被编码问题
因为mvc中从控制器中返回回来的字符串都是经过编译的,所以如果返回来的字符是HTML直接就进行了编译,显示出来的是经过编码的后的字符,为了能让HTML能正常的应用到页面,我们可以这样做,看下面说明:首先介绍一下MvcHtmlString:表示不应再次进行编码的 HTML 编码的字符串解决方案:ViewData["funHtml"] =new MvcHtmlStrin转载 2017-02-23 14:20:36 · 3742 阅读 · 0 评论 -
Part 66 - Check及Uncheck所有CheckBox 同时删除多行数据记录的实现
实现效果:勾选Name左边的CheckBox(后面部分简称‘它’),则所有CheckBox都会被选中, 再次Unckeck它,所有都不被选中;如果其他所有CheckBox都选中了,Name左边的CheckBox会自动选中;反之,如果其他的没有全部被选中,则它不会被自动选中或者由自动Uncheck.Controller代码如下:using MVC_DeleteMultiRow.Mod原创 2016-11-03 23:52:32 · 543 阅读 · 0 评论 -
Part 90 - Remote validation in mvc when javascript is disabled
Please watch Part 89 from asp.net mvc tutorial, before proceeding.Out of the box, Remote attribute only works when JavaScript is enabled. If the end user, disables JavaScript on his/her machine原创 2016-11-13 12:27:55 · 410 阅读 · 0 评论 -
Part 89 - Remote validation in asp.net mvc
Sometimes, to check if a field value is valid, we may need to make a database call.A classic example of this is the user registration page. To register a user, we need a unique username. So, to chec原创 2016-11-13 12:25:24 · 284 阅读 · 0 评论 -
Part 88 - Unobtrusive validation in asp.net mvc
Client side validation in asp.net mvc is unobtrusive. To turn on client side validation and unobtrusive JavaScript, make sure the following 2 keys under appSettings element within web.config file ar原创 2016-11-13 12:24:23 · 239 阅读 · 0 评论 -
Part 87 - What is Unobtrusive JavaScript
What is Unobtrusive JavaScript?Unobtrusive JavaScript, is a JavaScript that is separated from the web site’s html markup. There are several benefits of using Unobtrusive JavaScript. Separation of co原创 2016-11-13 12:23:25 · 194 阅读 · 0 评论 -
Part 86 - ValidationSummary in asp.net mvc
In this video, we will discuss displaying all validation errors at one place using validation summary html helper. A red asterisk (start) should be displayed next to every field that has failed the原创 2016-11-13 12:19:04 · 366 阅读 · 0 评论 -
Part 85 - Enable client side validation in asp.net mvc
Validation attributes in asp.net mvc provides both client and server side validation.There are 2 simple steps to enable client side validation in asp.net mvc.Step 1: Enable ClientValidation and Un原创 2016-11-13 12:17:46 · 312 阅读 · 0 评论 -
Part 84 - Compare attribute in asp.net mvc
Compare attribute is used to compare 2 properties of a model. Comparing email addresses and passwords is the common use case of Compare attribute. Let's understand using Compare attribute with an ex原创 2016-11-13 12:16:12 · 316 阅读 · 0 评论 -
Part 83 - RegularExpression attribute in asp.net mvc
Regular expression attribute is great for pattern matching validation. Let's understand using Regular expression attribute with an example. We will be continuing with the example that we started in翻译 2016-11-13 12:14:11 · 375 阅读 · 0 评论 -
Part 67 - Action selectors in mvc - ActionName AcceptVerbs
Actions are public methods in an mvc controller that responds to an URL request. You can control or influence which action method gets invoked using action selectors in mvc. Action selectors are att原创 2016-11-13 13:10:29 · 241 阅读 · 0 评论 -
Part 69 - Action filters in mvc
What are action filters in asp.net mvc?Action filters are attributes that can be applied either on a controller action method or on a controller. When applied at the controller level, they are appli原创 2016-11-13 13:12:55 · 211 阅读 · 0 评论 -
@Html.EditorForModel()用法
MSDN上对@Html.EditorForModel()的解释是Returns an HTML input element for each property in the model, using additional view data, 即使用另外一个View来为本VIew中Model每一个属性返回一个Html 输入元素。以Student类为例具体用法如下:1, 在Student原创 2016-11-03 23:08:20 · 4576 阅读 · 0 评论 -
Part 8 - Html.TextBox 和 Html.TextBoxFor 的区别
Let's understand the difference between TextBox and TextBoxFor & DropDownList andDropDownListFor HTML helpers with an example. Please watch Part 35, before proceeding. Right click on the "Mode转载 2016-10-18 10:11:16 · 5977 阅读 · 2 评论 -
Part 60 - ViewStart in asp.net mvc
To associate a view with a layout file, we have to set Layout property on each and every view. This violates DRY (Don't Repeat Yourself) principle, and has the following disadvantages1. Redundant co原创 2016-10-24 17:07:38 · 216 阅读 · 0 评论 -
Part 64 - MVC Sorting 排序
本文的效果是在 Part 62,及63 的基础上实现的。实现效果: 1. Name 和 Gender 列必须是可点击的超链接。 2. 点击 Name 或 Header,就可以实现排序功能, 如果没有点击 Name 或 Header, 则该列的数据以升序排列,如果点击了该列,数据降序排列 。 3. 默认情况下,数据按“Name”升序排列。原创 2016-10-25 17:38:21 · 224 阅读 · 0 评论 -
1 Creating a Web API Project
In this video we will discuss1. Creating a new ASP.NET Web API Project2. Explore and understand the Web API code auto-generated by Visual Studio For this course, we will be using Visual Studio 2原创 2016-11-13 13:46:53 · 453 阅读 · 0 评论 -
Part 72 - HandleError attribute in mvc
In this video, we will discuss HandleError attribute in asp.net mvc. HandleErrorAttribute is used to display friendly error pages to end user when there is an unhandled exception. Let us understand原创 2016-11-13 13:29:54 · 255 阅读 · 0 评论 -
Part 71 - childactiononly attribute in mvc
In this video, we will discuss childactiononly attribute in asp.net mvc. Let us understand this with an example. Step 1: Create a blank asp.net mvc 4 applicationStep 2: Add HomeController. Co原创 2016-11-13 13:21:01 · 590 阅读 · 0 评论 -
Part 70 - Authorize and AllowAnonymous action filters in mvc
In ASP.NET MVC, by default, all the controller action methods are accessible to both anonymous and authenticated users. If you want action methods, to be available only for authenticated and authori原创 2016-11-13 13:17:05 · 279 阅读 · 0 评论 -
Part 68 - What is the use of NonAction attribute in mvc
The following questions could be asked in an interviewWhat is the use of NonAction attribute in MVC?ORHow do you restrict access to public methods in a controller? An action method is a public原创 2016-11-13 13:14:55 · 228 阅读 · 0 评论 -
Part 82 - Creating custom validation attribute in asp.net mvc
At the moment, any value outside the range of "01/01/2000" and "01/01/2010" for HireDate filed, will raise a validation error. [Range(typeof(DateTime), "01/01/2000", "01/01/2010")][DisplayFormat(Da原创 2016-11-12 13:34:43 · 255 阅读 · 0 评论 -
Part 81 - Range attribute in asp.net mvc
RangeAttribute checks if the value of a data field is within a specified range of values. We will be working with the example, that we started in Part 80. Please watch Part 80, before proceeding.原创 2016-11-12 13:31:48 · 199 阅读 · 0 评论 -
Part 2 - View engines in asp.net mvc
Out of the box asp.net offers the following 2 view engines.1. ASPX2. RazorThere are 3 possible interview questions here, to test your understanding of view engines.1. What is the difference be原创 2016-10-14 15:36:31 · 155 阅读 · 0 评论 -
Part 3 - Using custom view engines with asp.net mvc
Out of the box ASP.NET MVC supports the following 2 view engines 1. ASPX2. Razor In addition to the above 2 view engines, there are several custom view engines that can be used with asp.net mvc.转载 2016-10-14 15:40:26 · 268 阅读 · 0 评论 -
Part 61 - Named sections in layout files in mvc
Let us understand sections in a layout file with an example. Please watch Parts 59 and 60 before proceeding. At the moment on all the views(Index, Create, Edit, Details & Delete), we see the sam原创 2016-10-24 20:49:15 · 176 阅读 · 0 评论 -
Part 54 - T4 templates in asp.net mvc
In this video, we will discuss1. What are T4 templates and their purpose2. Customizing T4 templates What are T4 templates and their purpose?T4 stands for Text Template Transformation Toolkit a原创 2016-10-24 17:04:41 · 223 阅读 · 0 评论 -
Part 53 - html.partial 和 html.renderpartial的区别
Let's discuss the difference between Partial() and RenderPartial() html helper methods. Both of these helper methods are used for rendering partial views. Differences:1. The return type of "Render原创 2016-10-24 17:02:40 · 461 阅读 · 0 评论 -
part 27- Customizing the autogenerated index view
使用Entity Framework的Database First自动生成扩展名为edmx的文件,然后又通过“包含视图的 MVC 控制器(使用Entity Framework)”的方法自动生成控制器和视图后。In this video we will discuss, customizing the auto-generated index view. At the moment,原创 2016-10-24 10:24:47 · 282 阅读 · 0 评论 -
Part 28 - Customizing the autogenerated create view
In this video we will discuss, customizing the auto-generated create view. (接part10)At the moment, none of the fields on "Create" view are required. This means,when you click on the "Create" butto原创 2016-10-24 10:34:39 · 186 阅读 · 0 评论 -
Part 29 - Using data transfer object as the model in mvc
In this video we will discuss, using data transfer object as the model in mvc. Please watch Part 28, before proceeding. Let's say the business requirement is such that, we want to display total原创 2016-10-24 11:05:00 · 161 阅读 · 0 评论 -
Part 6 - Generating a dropdownlist control in mvc using HTML helpers
To generate a dropdownlist, use DropDownList html helper. A dropdownlist in MVC is a collection of SelectListItem objects. Depending on your project requirement you may either hard code the values转载 2016-10-14 16:22:10 · 234 阅读 · 0 评论 -
Part 1 - What asp.net mvc version is my mvc application using
How to determine what version of asp.net mvc is being used by an existing mvc application?There are 2 ways1. At design time - In the solution explorer, expand "References" folder. Right click on原创 2016-10-14 15:14:39 · 245 阅读 · 0 评论 -
Part 63 - mvc 分页
By the end of this section, the index page should support both search functionality andpagination as shown below. Step 1: Install PagedList.Mvc using NuGet package manager. PagedList.Mvc is dep原创 2016-10-25 13:35:18 · 283 阅读 · 0 评论 -
Part 80 - mvc 中的 StringLength 属性
用法很简单,具体示例如下:StringLength attribute is present in System.ComponentModel.DataAnnotations namespace and is used to enforce minimum and maximum length of characters that are allowed in a data field.原创 2016-11-10 17:10:22 · 1648 阅读 · 0 评论 -
Part 78 - MVC中不同的ActionResult 类型
In this section, we will discuss different types of ActionResult objects that can be returned by an action method.The following is the signature of a typical action method in a controller. Notice原创 2016-11-10 16:10:32 · 370 阅读 · 0 评论 -
Part 52 - Partial views in mvc
If you are an asp.net web-forms developer, then you will realize that partial views in mvc are similar to user controls in asp.net webforms. Partial views are used to encapsulate re-usable view lo原创 2016-10-24 15:56:37 · 191 阅读 · 0 评论 -
Part 4 - How does a controller find a view in mvc
In this section, we will discuss the convention used by mvc to find views. Let's understand this with an example.''Notice that, the Index() action method does not specify the name of the view. So,转载 2016-10-14 16:12:45 · 219 阅读 · 0 评论 -
Part 76 - ValidateInput attribute in mvc 允许文本框输入html标签
只需设置ValidateInput属性为false,即可允许在文本框输入html标签。若需要详细了解,请往下看:This validateInput attribute is used to enable or disable request validation. By default, request validation is enabled in asp.net mvc, Let's原创 2016-11-10 15:41:55 · 1082 阅读 · 1 评论 -
Part 9 - Generating a radiobuttonlist control in mvc using HTML helpers
Right click on the "Models" folder and add a class file with "name=Company.cs". Copy and paste the following code.public class Company{ public string SelectedDepartment { get; set; } pub原创 2016-10-18 10:54:30 · 186 阅读 · 0 评论