.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

View validation - [Required]

Posted By:      Posted Date: October 11, 2010    Points: 0   Category :ASP.Net

Search thru the wau\y to do view input validation, have seen quite often refers this [Required], eg:

public class ProductViewModel {
  [Price(MinPrice = 1.99)]
  public double Price { get; set; }

  public string Title { get; set; }

What this [Required] actually is?
In which assembly?

View Complete Post

More Related Resource Links

Server-side validation on an Entity Framework required field (property) does not work!

Has anyone had issues getting server-side validation on an Entity Framework required field (property) to work? The data type is a string (nvarchar). Server-side validation for required fields of other data types WORK fine. Only string fields have issues. I get the following error on UpdateModel(obj); of my POST method within the controller. Exception Details: System.Data.ConstraintException: This property cannot be set to a  null value.Source Error: Line 4500:                OnTextChanging(value);Line 4501:                ReportPropertyChanging("Text");Line 4502:                _Text = StructuralObject.SetValidValue(value, false);Line 4503:                ReportPropertyChanged("Text");Line 4504:                OnTextChanged(); I've even tried data annotations like this but it seems to get ignored.     [MetadataType(typeof(ObjMD))]     public partial class Obj     {    

SSRS 2008 R2 Problem understanding View State Validation steps

Hi, Sorry, but I have some problem understanding this steps. Please help me to understand this.  Pasted from http://technet.microsoft.com/en-us/library/cc281307.aspx?lc=1033 How to Configure View State Validation To run a scale-out deployment on an NLB cluster, you must configure view state validation so that users can view interactive HTML reports. You must do this for the report server and for Report Manager. View state validation is controlled by the ASP.NET. By default, view state validation is enabled and uses the identity of the Web service to perform the validation. However, in an NLB cluster scenario, there are multiple service instances and web service identities that run on different computers. Because the service identity varies for each node, you cannot rely on a single process identity to perform the validation. To work around this issue, you can generate an arbitrary validation key to support view state validation, and then manually configure each report server node to use the same key. You can use any randomly generated hexadecimal sequence. The validation algorithm (such as SHA1) determines how long the hexadecimal sequence must be. Generate a validation key and decryption key by using the autogenerate functionality provided by the .NET Framework. (Well, how to generate Validation key using .Net Framework?) In the end, you must have a singl

View data input validation

I got a view has a dropdownlist and a text box for user input.And the form is set to POST.So in order to validate the input of the text box for his age, ie integer, should I use [HTTPPost] above the action body?And use overload method?eg.- Action 1 to show the view useActionResult ShowView()- after the user press 'Submit' button on the view redirect to the action[HTTPPost]ActionResult ShowView(int age){}Just wonder to validate the age, what happen if the input is not integer? Should I redirect to ShowView()?

how to do a ajax integrated validation in required field sharepoint newform.aspx

hi all, i have newform.aspx in sharpeoint list where in i have 2 cols which are reqd field. how would i make the server side validation without refreshing the page.. can i put it ajax update panel ?  how would i achieve this requirement.jayaraja

User does not have required permissions to view Report Manager on SQL 2008 r2

Hi all, We are installing SQL Server 2008 r2 onto a server, and this installation includes Reporting Services. SSRS works, I can deploy reports, use Report Manager, Report Builder, etc., all using my admin privs. The problem is when NON-ADMIN users connect to \\server\reports.  They get the following error: User 'DOMAIN\user' does not have required permissions.  Verify that sufficient permissions have been granted and Windows User Account Control (UAC) restrictions have been addressed. This error is resolved by giving the DOMAIN\user account local admin privs on the server. Granting admin privs is not a solution.  We have accountants and other non-technical people that will use Report Manager and Report Builder.  We can't just give every person admin privs on the production SQL server. I have done a lot of research on the web... I see a results involving earlier versions of SQL Server and Report Manager, but this is 2008 r2 - different webserver, etc. How can I resolve this issue?

Required Field Validation on Tabbing


Hello Friends,

I have Textbox-A and Textbox-B. Textbox-A is mandatory. 

If a user comes to Textbox-A and without entering anything if he moves to next available control (Textbox-B) either by tabbing or by moving the cursor,

error message should be displayed.

Could anyone of you please help me by telling in which event to write the validation.

Looking forward to hear from you ASAP.

Thanks in Advance


Strongly typed view validation


I have a strongly typed view with my model being entity framework.  In my controller I check for ModelState.IsValid.  When I submit my form without a value for a column that does not allow nulls it crashes before it gets to the ModelState.IsValid line and the error is about not allowing nulls in the column.  Shouldn't this be what is handled by the ModelState.IsValid line?  I feel like I am missing something obvious. 

Field validation failure on not required/blank drop-down box


I have a column in my list that is based on the records in another SharePoint list. When I try to edit a record in Datasheet View, I frequently get the following validation rule failure message:

The text entered for Client Impacted isn't an item from the list. Select an item from the list, or enter text that matches one of the listed items.

Even though the column appears to be blank to the naked eye, when you double click in the column, it selects what appears to be a space character and when you hit the delete key, it now passes the validation rule. So, my assumption is that the validation rule is saying something like "Space character isn't in the list, so you can't save the record..." Here's what's odd. I do NOT get the same validation rule warning when I edit in standard view and I know for sure that the column has not been erroneously filled with a space character. Anyone have any idea what might be going on here?

Thanks in advance for your help.


Assistance required on modifying a validation expression


I have found a very useful validation expression at http://regexlib.com/DisplayPatterns.aspx?cattabindex=2&categoryId=3  However, I want to make a couple of changes but am struggling a little!!

The expression is:


As per the link, this "regular expression will match on a real / decimal / floating point / numeric string with no more than 2 digits past the decimal. The negative sign (-) is allowed. No leading zeroes or commas. It is based on a currency regular expression by Tom Persing."

I would like to modify this as follows:

- Not match on numbers above 999
- Allow up to 5 digits past the decimal

How to localize "field is required" validation error message in mvc musicstore sample

I tried to localize codeplex mvc musicstore sample in .NET 3.5
I replaced "field is required"  message in all files with localized text.

In login of register screen, if some fields are empty, pressing enter still shows english language text like

The UserName field is required.

How to localize this validation message ?


Truly Understanding View State

This article provides a detailed understanding of the ViewState.

GridView Parent Child View with JQuery Effects

I was just checked how to add some more cool effects to the GridView control using JQuery. In this post I will display parent-child data in the GridView control with some help of the wonderful JQuery library.

Let's first populate the GridView control.

Model View Controller (MVC) for ASP.NET

Model View Controller (MVC) architectures, immediately wonder how the MVC pattern can be applied in an ASP.NET world. This article will demonstrate how the MVC pattern can be applied to an ASP.NET web application and still maintain the basic Microsoft supplied architecture.

jQuery grid view plugin

jqGridView is new, client-rich, XML-based, ajax grid plugin for jQuery library. jqGridView provides professional solution for representing and editing tabular data on the web. Carefully designed, with powerful script API, this editable DHTML grid is easy configurable with XML, and shows convincing results working with large amounts of data. jqGridView allows easy implementation of nice looking(managed through css). jqGridView is not platform-depending plug-in, it can be used with different web -programming platforms like: ASP .NET/ASP, PHP, JAVA, CGI scripts etc. jqGridView has hight bowser compatibility.

jQuery grid view plugin

jqGridView is new, client-rich, XML-based, ajax grid plugin for jQuery library. jqGridView provides professional solution for representing and editing tabular data on the web. Carefully designed, with powerful script API, this editable DHTML grid is easy configurable with XML, and shows convincing results working with large amounts of data. jqGridView allows easy implementation of nice looking(managed through css

view state vs request parameters


If  the view state is the data entered into the form fields then they are supposed to be available in the request parameters or request body. Then why would we need view state for?


Server side validation of Fileupload control not working



I've tried this method in my code behind to try and validate that the Fileupload control has a file or not. I get the error message the the event "Server Validate" cannot be found. Can anyone tell why? Thanks.

Public Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate

' Get file name

        Dim uploadAvatar As FileUpload = DirectCast(AdvertisementForm.FindControl("uploadAvatar"), FileUpload)

        Dim UploadFileName As String = uploadAvatar.PostedFile.FileName

        If UploadFileName = "" Then
            ' There is no file selected
            args.IsValid = False
            Dim Extension As String = UploadFileName.Substring(UploadFileName.L

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend