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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:28:08+00:00 2026-05-24T22:28:08+00:00

When the MVC view page with this textbox, loads , I would like to

  • 0

When the MVC view page with this textbox, loads , I would like to display current date and time by default. How can I do this? in razor.

  @Html.EditorFor(model => model.ReturnDate)
  • 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-24T22:28:08+00:00Added an answer on May 24, 2026 at 10:28 pm

    Before you return your model from the controller, set your ReturnDate property to DateTime.Now()

    myModel.ReturnDate = DateTime.Now()
    
    return View(myModel)
    

    Your view is not the right place to set values on properties so the controller is the better place for this.

    You could even have it so that the getter on ReturnDate returns the current date/time.

    private DateTime _returnDate = DateTime.MinValue;
    public DateTime ReturnDate{
       get{
         return (_returnDate == DateTime.MinValue)? DateTime.Now() : _returnDate;
       }
       set{_returnDate = value;}
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my view in ASP.NET MVC. <%@ Page Title= Language=C# MasterPageFile=~/Views/Administration.Master Inherits=System.Web.Mvc.ViewPage %>
How can i directly access a .cshtml file in ASP.NET MVC using razor view
I got a view that inherits : System.Web.Mvc.ViewPage<IEnumerable<MyProjects.Models.MyAccountWrapper>> In this view I list data
I need to instantiate some ASP LinkButtons onto an ASP.NET MVC view page. I've
I have a drop-down list hardcoded in an MVC View User Control page and
Using ASP MVC and Entity Framework. In the view, you have a page declaration
In an ASP.NET MVC view I'd like to include a link of the form:
I'm creating asp.net mvc login page. This is simple. Same as others. Controller contains
I have included the below in my MVC View page <%@ Page Title= Language=C#
I have HTML table on the ASP.NET MVC View page. Now I have to

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.