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 4007968
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:41:47+00:00 2026-05-20T08:41:47+00:00

I want to create a Date, Time and DateTime EditorTemplate using MVC3 and Razor.

  • 0

I want to create a Date, Time and DateTime EditorTemplate using MVC3 and Razor.

For now, let’s focus on the Time (I can fix the remaining templates later).

@model DateTime?

@using MyMvcApp.Properties

@Html.DropDownListFor(model => model.Value.Hour, new SelectList(new[] {"00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" },
    Model.HasValue ? Model.Value.Hour.ToString("D2") : "00"), null, new { style = "width: auto; margin-left: 5px;" })
:
@{
    List<string> availableMinutes = new List<string>();
    for (int minute = 0; minute < 60; minute += 1)
    {
        availableMinutes.Add(minute.ToString("D2"));
    }

    @Html.DropDownListFor(model => model.Value.Minute, new SelectList(availableMinutes, Model.HasValue? Model.Value.Minute.ToString("D2") : "00"), null, new { style = "width: auto" });
}


<img alt="@Resources.SelectTime" src="../../../images/icon_clock_2.gif" style="margin-right: 5px" />

<input id="clearDate" type="button" value="@Resources.Clear" class="ui-state-default" />

The point is: how do I clear values of this editor template only? I can add a script that clears the values of the ID’s, but then all the editortemplates of the same type would be cleared.

So my question: how can I clear all the values (hour and minute) of this template only when the clearDate button is clicked?

Thanks in advance!

  • 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-20T08:41:48+00:00Added an answer on May 20, 2026 at 8:41 am

    You could wrap the entire template in a div container and simply walk the DOM with jQuery in context to the clearDate button. I’m doing this from memory, but it would be something like:

    $(this).parent().children().contents().find("#hourElement").val("");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a Settings-Widget, where I can choose a Date. Because it
I'm using Perl's Calendar module to create a date, and I want to serialize
I am using: datetime.now() to get the current time in an Event app that
I want to create a file with date. DateTime time_now = DateTime::UtcNow; String^ time_str
I want to create a DateTime instance that lies 20 minutes and 10 seconds
I want to create date with specific format for e.g 03-20-2010 have a format
I've been using DisplayTemplates/EditorTemplates for relatively simple types, like DateTime and DateTime?, etc. Now
I am trying to create my own Date/Time field. I know there are a
I have a vector of temperatures and a cell array of Date/Time. I want
I'm trying to make an events page and I want to create 2 datetime

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.