editortemplates

ASP.NET MVC 3 Generic DisplayTemplates

十年热恋 提交于 2019-12-01 17:30:41
I've just started a project using ASP.NET MVC 3. I'm building on top of an existing object system, so one of the first things I have to do is define display and editor templates for the various types that exist. Is it possible in MVC to define a DisplayTemplate with a generic argument? For example, we have a BitString<T> class which takes an enumeration as the generic argument and represents a list of options wrapping the supplied enumeration. I'm hoping I can define a single Display/Editor template that handles all BitString instances. I'm currently using Razor for my views, but I don't mind

Too many JavaScript and CSS files on my ASP.NET MVC 2 Master Page?

為{幸葍}努か 提交于 2019-12-01 11:02:15
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

Can I Add to the Display/EditorTemplates Search Paths in ASP.NET MVC 3?

那年仲夏 提交于 2019-11-30 17:28:09
I have a standard set of templates for my mvc projects which I want to keep as an external folder in my source control (SVN) This means that I cannot put any project specific files in this folder as it will be committed to the wrong place.. .. and my standard templates need to override the ones that are used by MVC itself so they need to be in the place MVC expects overriding templates (e.g. ~/Views/Shared/EditorTemplates) So where can I put my project specific ones? Should I put them in ~/Views/Shared/SiteEditorTemplates, for example, and add the path to the search? How would I do that? Or an

Can I Add to the Display/EditorTemplates Search Paths in ASP.NET MVC 3?

两盒软妹~` 提交于 2019-11-30 16:48:23
问题 I have a standard set of templates for my mvc projects which I want to keep as an external folder in my source control (SVN) This means that I cannot put any project specific files in this folder as it will be committed to the wrong place.. .. and my standard templates need to override the ones that are used by MVC itself so they need to be in the place MVC expects overriding templates (e.g. ~/Views/Shared/EditorTemplates) So where can I put my project specific ones? Should I put them in ~

ASP.Net MVC 3 - Client side unobtrusive validation for Editor Templates

萝らか妹 提交于 2019-11-30 07:24:05
I am new to ASP.Net MVC 3, facing some issues while trying to implementing client side unobtrusive validation for a editor template I have created for showing date in a custom way. UI I need to show date in a three texbox UI format as I have put up a EditorTemplate for displaying the date in three parts as @model DateTime? <table class="datetime"> <tr> <td>@Html.TextBox("Day", (Model.HasValue ? Model.Value.ToString("dd") : string.Empty)) </td> <td class="separator">/</td> <td>@Html.TextBox("Month", (Model.HasValue ? Model.Value.ToString("MM") : string.Empty))</td> <td class="separator">/</td>

Problem with MVC EditorFor named template

放肆的年华 提交于 2019-11-30 01:48:40
I have what appears (to me anyway) to be a strange problem... I created a simple editor template for a SelectListItem (SelectListItem.cshtml in the ~/Views/Shared/EditorTemplates folder), for example: <ul class="select-list-item cell-15 col-3 omega clearfix"> @Html.EditorFor(c => c.Categories) </ul> Where c.Categories is an IEnumerable This worked fine, but I wanted another template to render the collection with slightly different markup, so I copied and renamed the editor template to, for example, 'CategoryIcons.cshtm' and invoked as follows: <ul class="select-list-item cell-15 col-3 omega

ASP.Net MVC 3 - Client side unobtrusive validation for Editor Templates

那年仲夏 提交于 2019-11-29 09:38:15
问题 I am new to ASP.Net MVC 3, facing some issues while trying to implementing client side unobtrusive validation for a editor template I have created for showing date in a custom way. UI I need to show date in a three texbox UI format as I have put up a EditorTemplate for displaying the date in three parts as @model DateTime? <table class="datetime"> <tr> <td>@Html.TextBox("Day", (Model.HasValue ? Model.Value.ToString("dd") : string.Empty)) </td> <td class="separator">/</td> <td>@Html.TextBox(

When do I use View Models, Partials, Templates and handle child bindings with MVC 3

╄→гoц情女王★ 提交于 2019-11-27 04:17:25
new to mvc3, i have a few questions, would appreciate if someone could answer/provide links: When should I use View Models? Is it not recommended to use the domain? I find that my view models are copies of my domain objects, and don't see the value... When should I use Partials? Is it only if the partial view will be reused? When should I use Display Templates and Editor Templates? Can I use these without a view model? How do I create an edit screen where the parent and list of child objects are both editable? i.e. a few fields at the top (parent) and a grid of fields below (like editable rows

In an Editor Template call another Editor Template with the same Model

不想你离开。 提交于 2019-11-26 20:36:02
问题 I have an editor template and within that editor template i want to call another editor template with the same model (i.e. nested), but it does not seem to display. ie. \EditorTemplates\Template1.cshtml @model foo // insert code here to edit the default fields. // display extra fields via another editor template. @Html.EditorForModel("Template2") // or @Html.EditorFor(m => m, "Template2") and \EditorTemplates\Template2.cshtml @model foo @Html.TextBoxFor(m => m.Name) I am sure someone will

How to create custom editor/display templates in ASP.NET MVC 3?

柔情痞子 提交于 2019-11-26 15:12:43
I would like to make custom editor templates for different data types in ASP.NET MVC (to use with Html.EditorFor() ), including rewriting the existing templates. The ultimate goal is to create a mini-framework where each editor supports javascript notifications about being changed, and I can show a message to the user that there are unsaved changes in the page. (Maybe there's something existing already?) I can find many questions pertaining to problems with such templates, but nowhere can I find a tutorial or manual on creating them. Where do they go? Is there any special syntax? How does a