You can pass html attributes like "maxlength" or width (via "style") from the view to an editor template using EditorFor.
Here’s how you do it:
View full article »
You can pass html attributes like "maxlength" or width (via "style") from the view to an editor template using EditorFor.
Here’s how you do it:
View full article »
This article shows you how to easily protect against CSRF attacks using MVC.NET’s ValidateAntiForgeryToken and prompt a user with a confirmation popup using jquery UI when submitting a form to multiple controller actions. Code examples are included for jquery.UI version 1.8.9 with the redmond theme and ASP.NET MVC 3 in a form with two secure submit input buttons to get a neat confirmation dialog:
You can automagically format dates and add a jquery datepicker to the input box for all DateTime (and nullable DateTime) properties for your view. You just need to add a DateTime.ascx partial view to your Views/Shared/EditorTemplates folder and use the standard Html.EditorFor helper for date properties in your views. Here’s the details:
Microsoft has made a change to the behavior of TempData that we need to be aware of in MVC 2 and 3. TempData now no longer completely clears at the end of a controller action cycle. TempData can now (automatically and without you changing anything) persist through to other pages. TempData keys are now only cleared if they’ve been read. Furthermore, if you use RedirectResult or RedirectToRouteResult, they will persist even if they are read. These changes could potentially be very bad where we have coded under the old assumption.
Here’s the details:
View full article »
If you have a entity with a nested entity, you can show the nested entity’s properties with a little trick.
For example if you have these business objects:
public class MyObj
{
public MyOtherObj MyProperty { get; set; }
}
public class MyOtherObj
{
public int SomeProperty { get; set; }
}
If you want to show a field from MyProperty (e.g. MyOtherObj.SomeProperty), and MyObj is your report’s datasource, your report fieldbox will need to look like this:
First(Fields!MyProperty.Value.SomeProperty)
(NOTE: do not add “.Value” onto the end of the property name as normal, it will produce a #error at runtime).