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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T09:51:25+00:00 2026-05-16T09:51:25+00:00

I’m a beginner at ASP.NET and I was learning how to use it through

  • 0

I’m a beginner at ASP.NET and I was learning how to use it through this tutorial. I use Linux, so I’m using Mono 2.6.7. I’ve had to stray off the path of the tutorial several times to get things to work under Mono (including using a patched version of MVC 2 that I would link to, but I am unable to as new users can only post one hyperlink), but there’s one problem that I haven’t been able to fix: form validation. I set up my validation metadata like this:

using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;

namespace MvcMusicStore.Models
{
 [MetadataType(typeof(AlbumMetaData))]
 public partial class Album
 {
  [Bind(Exclude = "AlbumID")]
  public class AlbumMetaData
  {
   [ScaffoldColumn(false)]
   public object AlbumID { get; set; }

   [DisplayName("Genre")]
   public object GenreID { get; set; }

   [DisplayName("Artist")]
   public object ArtistID { get; set; }

   [Required(ErrorMessage = "An Album Title is required")]
   [StringLength(160)]
   public object Title { get; set; }

   [DisplayName("Album Art URL")]
   [StringLength(1024)]
   public object AlbumArtUrl { get; set; }

   [Required(ErrorMessage = "Price is required")]
   [Range(0.01, 100.00, ErrorMessage = "Price must be between 0.01 and 100.00")]
   public object Price { get; set; }
  }
 }
}

And I set up my View like this:

<p>
    <%= Html.LabelFor(model => model.Title) %>
 <%= Html.TextBoxFor(model => model.Title) %>
    <%= Html.ValidationMessageFor(model => model.Title) %>
</p>

<p>
 <%= Html.LabelFor(model => model.Price) %>
 <%= Html.TextBoxFor(model => model.Price) %>
 <%= Html.ValidationMessageFor(model => model.Price) %>
</p>

<p>
 <%= Html.LabelFor(model => model.AlbumArtUrl) %>
 <%= Html.TextBoxFor(model => model.AlbumArtUrl) %>
 <%= Html.ValidationMessageFor(model => model.AlbumArtUrl) %>
</p>

However, when I test the form by giving it bad data, I don’t get the error messages I set. When I leave “Title” blank, I get: “Validation error (System.ComponentModel.DataAnnotations.RequiredAttribute): Title”, and I get a similar error when I leave Price blank. If I enter an out-of-range number for “Price” or a long string for “Title” or “AlbumArtUrl”, the script ignores the problem, doesn’t leave an error message and lets the form submit; however, if I type a very large number into “Price”, I get “The value ‘large number‘ is invalid.”.

How can I fix this? Is there an alternate method to Html.ValidationMessageFor that I can use? Is it a problem with my model? Is it just a problem with Mono? Please help!

  • 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-16T09:51:26+00:00Added an answer on May 16, 2026 at 9:51 am

    It looks like the [Required] and [Range] attributes aren’t really implemented in Mono. They are just stubs so that you can compile your application.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am trying to loop through a bunch of documents I have to put
I'm making a simple page using Google Maps API 3. My first. One marker
I have some data like this: 1 2 3 4 5 9 2 6
I have a bunch of posts stored in text files formatted in yaml/textile (from

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.