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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:15:44+00:00 2026-05-26T19:15:44+00:00

I have a hidden field on a form that is created in Razor using

  • 0

I have a hidden field on a form that is created in Razor using the @Html.HiddenFor helper:

@Html.HiddenFor(model => model.BidID, new { id="bidItemID" })

My View model looks like this:

public class BidEditVM
{
    [Display(Name = "Bid ID")]
    public int BidID { get; set; }

    [StringLength(51)]
    [Display(Name = "Customer Name")]
    public string CustomerName { get; set; }

    [StringLength(75)]
    [Display(Name = "Bid Name")]
    public string BidName { get; set; }

    [Display(Name = "Amount")]
    public decimal Amount { get; set; }

    [Display(Name = "Time")]
    public DateTime BidTime { get; set; }
}

When the HTML is rendered, unobtrusive javascript adds it’s stuff to the hidden input field even though it will never require validation:

<input id="bidItemID" type="hidden" value="5198" name="BidID" data-val-required="The Bid ID field is required." data-val-number="The field Bid ID must be a number." data-val="true">

What’s odder is that the message and validation it adds aren’t even part of the view model for this partial view. The view looks like this:

@model AuctionAdmin.Models.ViewModels.BidEditVM

@using (Ajax.BeginForm("UpdateBid", new AjaxOptions { HttpMethod = "Post", UpdateTargetId = "modalBidInfo" }))
{
    @Html.ValidationSummary(true)
    @Html.HiddenFor(model => model.BidID, new { id="bidItemID" })

    <fieldset>
        <legend>Edit Bid</legend>

        <div class="display-label">@Html.LabelFor(model => model.CustomerName)</div>
        <div class="display-field">
            @Html.DisplayFor(model => model.CustomerName)
        </div>

        <div class="display-label">@Html.LabelFor(model => model.BidName)</div>
        <div class="display-field">
            @Html.DisplayFor(model => model.BidName)
        </div>

        <div class="editor-label">@Html.LabelFor(model => model.Amount)</div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Amount)
        </div>

        <div class="editor-label">@Html.LabelFor(model => model.BidTime)</div>
        <div class="editor-field">
            @Html.EditorFor(model => model.BidTime)
        </div>
    </fieldset>
}

Where is it getting this metadata from and how can I stop it?

  • 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-26T19:15:45+00:00Added an answer on May 26, 2026 at 7:15 pm

    It’s marked as such since the type in the view model is an int.

    It’s adding the html due to this line:

    @Html.HiddenFor(model => model.BidID, new { id="bidItemID" })
    

    Why is it a problem that the extra attributes are present?
    If it really is problematic, try changing the type of BidId to int? (a nullable int).

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

Sidebar

Related Questions

I have a field in a CCK node form that is hidden, and has
I have a form with a hidden Came from Adwords field that will be
I have a register form created by mvc3 scaffolding. e.g. <div class=editor-label> @Html.LabelFor(model =>
I have a form with a bunch of checkboxes, and a hidden field that
I have an hidden input field with a value, <form> <input type=hidden value=product/> <select
I have a hidden button on a form that I need to click in
I have a complex form for a model Schedule that belongs to a parent
I have a form to create a new record. I have that partial that
I have a hidden embedded QuickTime object on my page that I'm trying to
I have a dynamic form that I've written in rails. I want to be

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.