Articles : Page 2 of 2
- Filter:
- Viewdata
-
Integrate Html5 Form in ASP.NET MVC
Oct 1020This article is divided into three parts. In the first, part I will show you how you can add Html5 forms in your ASP.NET MVC application with very minimum effort. In the second part, I will show you how to implement client side validation which will trigger automatically even when the browser does not have the html5 client side validation support and in the last part I will show widgetify the form in the client side with jQuery for the older browser that does not have support for Html5 form. ...
-
MVC 2 Model Metadata to Render Dynamic UI
Sep 1009Recently we had a project where we needed to render certain questions on the screen dynamically based on answers to previous questions on previous screens. For questions that need to dynamically be visible/invisible on the same screen, this can simply be controlled with jQuery. However, in this case, based on the user’s input on previous screens we know there are certain questions that will not be applicable before the current screen even loads. In this case, we could use jQuery to set those...
-
What is the difference in <%: variable%> and <%= variable%> in ASP.NET MVC?
Aug 1023With many folks adopting ASP.NET MVC as well as Visual Studio 2010, there is a fairly confusing change if you are one of those people who doesn’t engage in the alpha and beta phases of new product releases from Microsoft or any other vendor, for that matter. The issue of <%: vs. <%= has had a great deal of discussion around it in the years leading up to the Visual Studio 2010 release. This new expression syntax, or code nugget, is a new feature of ASP.NET 4. It applies equally to ASP.NET Web...
-
Unit Testing Secure Controller Actions with Moq
Aug 1015One of the hardest things to unit test in MVC is security. Security is tough to test because there is a lot of setup involved in mocking the HttpContext, the Principal and the Identity. For example, in WeBlog I am using the following code in the Edit Post action. Post post = Repository.FirstOrDefault<Post>(x => x.ID == id); if (post == null) return View(NotFound if (!HttpContext.User.CanEditPost(post)) return View(PermissionDenied In order to make sure this code works properly I need to t...
-
Dynamic Methods in View Data
Aug 1002In ASP.NET MVC 3 Preview 1, we introduced some syntactic sugar for creating and accessing view data using new dynamic properties. Sugar, it’s not just for breakfast. Within a controller action, the ViewModel property of Controller allows setting and accessing view data via property accessors that are resolved dynamically at runtime. From within a view, the View property provides the same thing (see the addendum at the bottom of this post for why these property names do not match). Disc...
- 1
- 2

