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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:23:34+00:00 2026-05-30T01:23:34+00:00

The standard output of @Html.HiddenFor(model => model.Id) is <input data-val=true data-val-number=The field Id must

  • 0

The standard output of @Html.HiddenFor(model => model.Id) is

<input data-val="true" data-val-number="The field Id must be a number." data-val-required="The Id field is required." id="Id" name="Id" type="hidden" value="0" />

Is there a need for the generation of the data-val-* attributes? They seem rather verbose and not needed just to be able to store and return data for the next POST.

Is it a good idea to disable these attributes? Are they usefull for some scenario’s?

ps: Currently I have a way to disable them by temporarily setting ViewContext.UnobtrusiveJavaScriptEnabled = false

using these two classes:

public static class Extensions
{
    public static NoUnobtrusiveJavaScript NoUnobtrusiveJavaScript(this HtmlHelper htmlHelper)
    {
        return new NoUnobtrusiveJavaScript(htmlHelper.ViewContext);
    }
}

public class NoUnobtrusiveJavaScript: IDisposable
{

    private bool _disposed;
    private readonly bool _unobtrusiveJavaScript;
    private readonly ViewContext _viewContext;

    public NoUnobtrusiveJavaScript(ViewContext viewContext)
    {
        if (viewContext == null) {
            throw new ArgumentNullException("viewContext");
        }

        _viewContext = viewContext;
        _unobtrusiveJavaScript = viewContext.UnobtrusiveJavaScriptEnabled;
        _viewContext.UnobtrusiveJavaScriptEnabled = false;
    }

    public void Dispose()
    {
        Dispose(true /* disposing */);
        GC.SuppressFinalize(this);
    }

    protected virtual void Dispose(bool disposing)
    {
        if (!_disposed)
        {
            _disposed = true;
            // restore the original UnobtrusiveJavaScriptEnabled state
            if (_viewContext != null)
            {
                _viewContext.UnobtrusiveJavaScriptEnabled = _unobtrusiveJavaScript;
            }
        }
    }

    public void EndForm()
    {
        Dispose(true);
    }
}

* pattern following the Html.BeginForm code from FormExtensions.cs and MvcForm.cs

  • 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-30T01:23:36+00:00Added an answer on May 30, 2026 at 1:23 am

    Just because the field is hidden, doesn’t neccesarily mean you don’t want the validation. You might be manipulating the hidden field via javascript, and want to keep the built in validation so you don’t have to do your own.

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

Sidebar

Related Questions

I'm collecting information in a standard HTML form. I have, for example, <input type=text
Why is it necessary to close standard input/output/error when writing a (unix) daemon?
With the C standard library stdio.h , I read that to output ASCII/text data,
Is there an standard output library that knows that php outputs to html? For
The standard html output created by Seaside is all in one line, without any
I have a program that creates a html file as standard output. To view
I've got a bunch of HTML form field data coming in as a hash,
Which Windows Shell command will print a file content on the standard output (like
How do I detect from within a shell script if its standard output is
I've posted the same question here a few days ago( Java reading standard output

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.