Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5840393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:44:18+00:00 2026-05-22T11:44:18+00:00

<%= Html.TextBoxFor(m => m.Trx.TradeDate, new { @class = economicTextBox, propertyName = Trx.TradeDate, dontRegisterNewIndication =

  • 0
<%= Html.TextBoxFor(m => m.Trx.TradeDate, new { @class = "economicTextBox", propertyName = "Trx.TradeDate", dontRegisterNewIndication = true })%>

Since this is a TextBoxFor, I can’t just change the way it’s displayed (I don’t think?), because I have to have that specific property value I’m binding this to.

This is displaying the full DateTime though – 5/18/2011 10:21:22 AM

How do I get it to only display the 5/18/2011 portion?

Should I do it through Javascript? This field is made as a JQuery DatePicker field as well.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T11:44:19+00:00Added an answer on May 22, 2026 at 11:44 am

    You can define an EditorTemplate for DateTime, either in the EditorTemplates folder in your view, or in /Views/Shared/EditorTemplates.

    Then call <%= Html.EditorFor(m => m.DateTimeProp) %>.

    \Views\Shared\EditorTemplates\DateTime.ascx:

    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<DateTime?>" %>
    <%= Html.TextBox(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty), Model.HasValue ? Model.Value.ToString("dd-MM-yyyy") : string.Empty) %>
    

    Alternately:

    You can also add your own HtmlHelper extension, like DateTimeTextBoxFor. Unfortunately, the templates used by the ____For default extensions have a rather static template.

    Another Alternative:

    You can use Data Attributes to control the data type and format, however, I think you still need to use EditorFor to get those to work (although, it wouldn’t require a separate ASCX file).

    [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd-MM-yyyy}")]
    public DateTime DateTimeProp { get; set; }
    
    <%= Html.EditorFor(m => m.DateTimeProp) %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<%= Html.TextBoxFor(m => m.STPData.ProjectName, new { @class = economicTextBox, disabled=disabled, propertyName = STPData.ProjectName, onchange
We have this textbox: <%= Html.TextBoxFor(m => m.FloatingComponent.IndexOptions.Lookbackdays, new { @class = economicTextBox DontShrinkBigger,
I have this text-box on the page: <%= Html.TextBoxFor(m => m.STPData.ProjectName, new { @class
Trying to set this textbox <%= Html.TextBoxFor(m => m.IndicationCalculatorNewGroupName, new {propertyName = IndicationCalculatorNewGroupName, onchange
I just started using MVC3. I am using fields like this: <div class=editor-field> @Html.TextBoxFor(model
For example, if i use this in view: ${Html.TextBoxFor(u=>u.UserName)} How can i var name
I have tried: @Html.TextBoxFor(m => m.UserName, new {@class='textbox'}) which isn't working.
I have this : @Html.TextBoxFor(m => m.MyClass.MyValue, new { style = width: 138px, id
I want to do this @Html.TextBoxFor(x => x.BackgroundColor, new { style = width: 20px;
Html.TextBox(ParentPassword, , new { @class = required }) what the gosh darned heck is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.