JavaScript and CSS files for ASP.NET MVC 2 EditorTemplate user controls
Posted
by Zack Peterson
on Stack Overflow
See other posts from Stack Overflow
or by Zack Peterson
Published on 2010-05-17T21:24:35Z
Indexed on
2010/05/17
21:31 UTC
Read the original article
Hit count: 753
I'm using an EditorTemplate DateTime.ascx
in my ASP.NET MVC 2 project.
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<DateTime>" %>
<%: Html.TextBox(String.Empty, Model.ToString("M/dd/yyyy h:mm tt")) %>
<script type="text/javascript">
$(function () {
$('#<%: ViewData.TemplateInfo.GetFullHtmlFieldId(String.Empty) %>').AnyTime_picker({
format: "%c/%d/%Y %l:%i %p"
});
});
</script>
This uses the Any+Time™ JavaScript library for jQuery by Andrew M. Andrews III.
I've added those library files (anytimec.js
and anytimec.css
) to the <head>
section of my master page.
Rather than include these JavaScript and Cascading Style Sheet files on every page of my web site, how can I instead include the .js and .css files only on pages that need them--pages that edit a DateTime type value?
© Stack Overflow or respective owner