Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

DatePicker Editor Template - ASP.NET MVC

RSS
Modified on Mon, Apr 14, 2014, 9:37 AM by Administrator Categorized as ASP·NET MVC

Usage

Within a Razor view for a model with a DateTime property

@Html.EditorFor(m => m.MyDateTimeProperty, "DatePicker")

Reusable Code

Razor Markup

Create a Razor view called "DatePicker.cshtml" within your /Views/Shared/EditorTemplates folder

@model System.DateTime
@{
    ViewData["class"] = ViewData["class"] + " datepicker";
}
@Html.TextBoxFor(m => m, "{0:MM/dd/yyyy}", ViewData)

JavaScript

This assumes you have jQuery UI loaded.

$('.datepicker').datepicker()

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.