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

  • Home
  • SEARCH
  • 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 807463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:24:09+00:00 2026-05-15T00:24:09+00:00

I am using Model binding with the Entity Framework and have an Html.TextBoxFor(model =>model.date)

  • 0

I am using Model binding with the Entity Framework and have an Html.TextBoxFor(model =>model.date) input. I know how to tell jQuery how to implement a datepicker but not in this context. What would I need to add here to have a calendar popup when the user enters this field?

  • 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-15T00:24:10+00:00Added an answer on May 15, 2026 at 12:24 am

    You’ll want to use the HtmlHelper overload that allows you to specify Html attributes. Then target them with the jquery selector.

    // in view
    <%= Html.TextBoxFor(x => x.Date, new { @class="datepicker" })%>
    
    // in js
    $(document).ready({
             $('.datepicker').datepicker();
        });
    

    Though I recommend using EditorFor instead.

    <%= Html.EditorFor(x => x.Date)%>
    

    You can create an EditorTemplate to handle any field that is a DateTime and have it output the proper field.

    Create /Views/Shared/EditorTemplates/DateTime.ascx and put this in it…

    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.DateTime>" %>    
    <%= Html.TextBox("", Model.ToShortDateString(), new { @class="datepicker" } )%>
    

    Or if you need to allow DateTime’s with nulls:

    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.DateTime?>" %>    
    <%= Html.TextBox("", (Model.HasValue? Model.Value.ToShortDateString():""), new { @class="datepicker"} )%>
    

    Then you can always use EditorFor and have a central ascx to edit if you ever want to modify the way date times are handled in your views.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using MVC3 with Entity Framework Code First. I have the following model.
I am learning to develop windows forms application with Entity Framework using Model View
I am getting started with Entity Framework 4, using model-first development. I am building
Using MVVM and EF...I have a datagrid binding to a View Model (using ObservableCollection).
I have a generic repository that is using Entity Framework 4 with the DbContext
I'm using Entity Framework 4 and with a Database First binding, and EF is
I am using Entity Framework 4 with the Service/Repository/EF4/POCO classes technique, and I have
Question: How do send data to a view model when using command binding? So
I'm using a model produced with Devart Entity Developer (.edml file, which I understand
I'm using the Entity Framework version 4.2. There are two classes in my small

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.