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

The Archive Base Latest Questions

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

I have a view and it uses TextBoxFor helper method to edit model. Like

  • 0

I have a view and it uses TextBoxFor helper method to edit model. Like this:

<div class="editor-field">
                <%:Html.TextBoxFor(model => model.Property, new { @class = "mybox" })%>
                <%: Html.ValidationMessageFor(model => model.Property)%>
</div>

So, Modelbinder works fine and I can edit and save my model.

When I add html5 attributes ‘type’ and ‘step’ like this

<div class="editor-field">
                <%:Html.TextBoxFor(model => model.Property, new { @class = "mybox",@type = "number", @step = "1" })%>
                <%: Html.ValidationMessageFor(model => model.Property)%>
</div>

I see beautiful numeric control instead of textbox, but modelbinding brakes and whenever I change my Property I recieve 0 in my model.Property on submit.

What’s wrong with my code?

That’s my simple model

public class Model
    {

        [DisplayName("Property")]
        public int Property
        {
            get;
            set;
        }           
    }

Nathan, my explanation of the problem is not precise here. Here Ajax Form breaks after adding html5 attributes in Chrome/Safari is a better description and workaround.

  • 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-24T14:08:20+00:00Added an answer on May 24, 2026 at 2:08 pm

    Give this a try:

    http://deanhume.com/Home/BlogPost/asp-net-mvc-html5-toolkit/29

    Based on your code, this works for me:

    Controller:

    public class IndexController : Controller
    {
    
        public ActionResult Index()
        {
            return View();
        }
    
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Index(Model model)
        {
            return Content(model.Property.ToString());
        }
    
    }
    

    Model:

    public class Model
    {
        [DisplayName( "Property" )]
        public int Property
        {
            get;
            set;
        }
    }
    

    View:

    <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<BindTest.Models.Model>" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
        <head runat="server">
            <title>Index</title>
        </head>
        <body>
        <%using( Html.BeginForm( "index", "index" ) ){ %>
            <div class="editor-field">
                <%=Html.TextBoxFor(model => model.Property, new {@class = "mybox", @type = "number", @step = "1"})%>
                <%=Html.ValidationMessageFor(model => model.Property)%>
            </div>
    
            <button type="submit" value="click Me">Click Me</button>
    
        <% } %>
        </body>
    </html>
    

    When I click my submit button, the number selected in my numeric input control is received by the controller and output to the browser.

    We’ll need to see more code to be more helpful.

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

Sidebar

Related Questions

I have a view that uses a list of modelitems like this: List<It4You.AlertBrick.Library.Domain.Order.AbOrderLineItemPicked> When
i have a view controller that uses the getDistance method for calculating the distance
I have a view that uses a strongly typed ViewData similar to this: namespace
I have a model like so: return new MyViewModel() { Name = My View
I have a very simple viewmodel class, and a strongly typed view (which uses
Given a View uses a Presenter, and in the presenter you have a model.
I have a view model which uses custom attributes such as public int Id
Background: I have an MVC layout (master) view which uses @Html.RenderAction to display a
I have a view that uses one of the class-based generic views (derives from
I have used a list view that uses a grid view in WPF. I

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.