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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:35:59+00:00 2026-06-08T05:35:59+00:00

I am using a TextBoxFor to display an editable field. I need this field

  • 0

I am using a TextBoxFor to display an editable field. I need this field to display a value of “150” but allow the value to be changed.

I have tried using @Html.TextBoxFor(m => m.MembershipDues, new { @Value = "150" }) but this is not working for me.

Here are my Model’s Fields:

[Required]
    [DataType(DataType.Text)]
    public decimal MonthlyPayment { get; set; }

    [Required]
    [DataType(DataType.Text)]
    public decimal MaintenanceFees { get; set; }

    [Required]
    [DataType(DataType.Text)]
    public decimal MembershipDues { get; set; }

    [Required]
    [DataType(DataType.Text)]
    public decimal ExchangeFees { get; set; }

    [Required]
    public string Duration { get; set; }

    public decimal AnnualPayment { get; set; }
    public decimal AnnualMaintenance { get; set; }
    public decimal AnnualTotal { get; set; }
    public decimal TenYearPayment { get; set; }
    public decimal TenYearMaintenancePercentage { get; set; }
    public decimal TenYearMembershipAndExchange { get; set; }
    public decimal TenYearTotal { get; set; }
    public decimal AnnualVacationCost { get; set; }

Here’s my Action

        [OutputCache(Duration = 60)]
    public ActionResult CalculationView()
    {         
        return View();
    }

    [HttpPost]
    [OutputCache(Duration = 60)]
    public ActionResult Index(CalculaterModel cm)
    {
        if (ModelState.IsValid)
        {
            if (cm.Duration == "Annual")
                cm.AnnualMaintenance = cm.CalculateMaintenanceFeesAnnually(cm.MaintenanceFees);
            else if (cm.Duration == "Monthly")
                cm.AnnualMaintenance = cm.CalculateMaintenanceFeesMonthly(cm.MaintenanceFees);

            cm.AnnualPayment = cm.MonthlyPayment * 12;
            cm.AnnualTotal = cm.AnnualPayment + cm.AnnualMaintenance;
            cm.TenYearPayment = cm.AnnualPayment * 10;

            decimal percentage = .08m;
            decimal cost;
            int i = 1;
            decimal rate = cm.AnnualMaintenance;
            while (i <= 10)
            {
                cost = rate * percentage;
                rate = cost + rate;
                cm.TenYearMaintenancePercentage = cm.TenYearMaintenancePercentage + rate;
                i++;
            }
            decimal MDF = cm.MembershipDues + cm.ExchangeFees;
            cm.TenYearMembershipAndExchange = MDF * 10;
            cm.TenYearTotal = cm.TenYearMembershipAndExchange + cm.TenYearMaintenancePercentage + cm.TenYearPayment;
            cm.AnnualVacationCost = cm.TenYearTotal / 10;
            return View(cm);
        }
        return View();
    }

I need for my textbox to display “150” and to be editable.
Any help will be greatly appreciated. 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-06-08T05:36:01+00:00Added an answer on June 8, 2026 at 5:36 am

    There’s a sometimes confusing issue where is you don’t specify your model with your view you won’t get default values set even if they are set using the Razor syntax.

    Change

    return View();
    

    With

    var cm = new CalculaterModel();
    return View(cm);
    

    And see if that works.

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

Sidebar

Related Questions

I need this displayfor to update its value from using jquery. I tried .val()
I can do this easily using a TextBoxFor but how do I do it
@using (Html.BeginForm()) { @Html.TextBoxFor(m => m.Name, new { @Value = Name }) @Html.TextBoxFor(m =>
I am using the following to display a label and then the value of
So I have a big trouble handling the ICollection field on this model This
I have a Model that I can bind correctly for display purposes but I
Something strange is happening here. I have a basic form: <% using (Html.BeginForm()) {
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
Using CI for the first time and i'm smashing my head with this seemingly
I have my page where i have ajax call to display form. My code

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.