.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

Issue with validation using IDataErrorInfo with int range

Posted By:      Posted Date: September 05, 2010    Points: 0   Category :WPF
Hi, I have a textbox which takes only numbers as input. Textbox has binding with int type property. <TextBox Name="TXT_From" Text="{Binding Path=Range, UpdateSourceTrigger=LostFocus,<br/>  ValidatesOnDataErrors=True, Mode=TwoWay}" /> public int Range { get { return (int)GetValue(RangeFromProperty); } set { SetValue(RangeFromProperty, value); } } public static readonly DependencyProperty RangeFromProperty = DependencyProperty.Register("Range", typeof(int), typeof(MyClass)); In IDataErrorInfo I am doing some auto correction of values. public string this[string property] { get { string msg = null; switch (property) { case "Range": if (Range < 0) Range = 1; if (Range > Max) Range = TempMax; break; default: throw new ArgumentException("Unrecognized property: " + property); } return msg; } } Now the issue is when I enter value greater than 2,147,483,647 which is max value for int the IDataErrorInfo member public string this[string property] is not getting called,also it displays red bordered textbox. I want to avoid this validation and dont want restriction on value input. How to achieve this?  

View Complete Post

More Related Resource Links

User validation Issue in xlsx file



I am validating user from Login.xlsx file. It was working fine by validating email and password from that file. For testing i got new file same contents of file but added some more user names.

So after that when i validating the user i am getting the following error "Data type mismatch in criteria expression".

But when i replaced the new to old one it is working fine. The contens of both files are the same. So why this kind of error happened.


XmlReader.Create(textReader, XmlReaderSettings) Validation Issue

For the most part, when I perform an XmlReader.Read() I am catching validation errors based on my schemas.  This, however, is a large group of schemas with several imports and includes.  My question is why I'm having validation errors in two places that seem to be defined in the schema.   Here's an example:   Schema 1 (you can see that IdentificationType has sub-elements for IdentificationID and IdentificationCode):   <xsd:complexType name="IdentificationType">                 <xsd:annotation>                         <xsd:documentation>A data type for a representation of an identity.</xsd:documentation>                         <xsd:appinfo>                                 <i:Base i:namespace="http://niem.gov/niem/structures/2.0" i:name="Object"/>               &nb

DataGrid ValidationRule or IDataErrorInfo validation code called multiple times for each data change

Following my enquiry regarding a problem in Datagrid validation, for which managing exceptions is apparently a problem, I tested the two other methods: using validation rules, or implementing the IDataErrorInfo interface. I ran into other problems there, more insidious this time. This has been done on Windows7 (32-bit), .NET 4.0.30319. 1) IDataErrorInfo When this interface is implemented, the this[string columnName] property is called four times for each modification: two times before the cell enters edit mode (with the old value in the corresponding property) two times when the new value has to be validated (with the new value) It strikes me as not really efficient, is there something wrong with my code? Here's the C# part: using System; using System.Windows; using System.Collections.ObjectModel; using System.ComponentModel; namespace DataGridTest2 { public partial class MainWindow : Window { ObservableCollection<User> users; public MainWindow() { InitializeComponent(); users = new ObservableCollection<User>() { new User { Name = "Teddy", Age = "2" }, new User { Name = "Avi", Age = "19" } }; datagrid.ItemsSource = users; datagrid.Focus(); } } public class User : INotifyPropertyChanged, IDataErrorInfo { string name; public string Name

XML schema validation issue

In case a particular node is mandatory, the error described is for the next sibling. In case there exists a error for the next sibling as well. That error message is supressed. On resolving the first issue, and running the validation again, the second error is thrown. Is there a way we can set options on the schema validation, so that we can receive both errors at the same time. For example we have a xml with the following nodes <NM101></NM101> <NM102></NM102> <NM103></NM103> Here NM101 is a mandatory node and NM102 has type as integer. In case we receivethe below xml <NM102>ABC</NM102> <NM103>DEF</NM103> Error: The element 'NM1' has invalid child element 'NM102'. List of possible elements expected: 'NM101' But the error for NM102 is now supressed and can be retrieved only when NM101 is present. Is there a way that all errors can be reported at the same time ?Swapnil Kasodekar

character limit in textbox in range validation

Hey,I am inserting some text in texbox and there is range validation set as minimum as 10 and maximun as 100. But when i run the program, though i insert the text atleast or more than 10 characters, it is showing the error message of this range validation. So I am confused how to set range so that user has to input atleast 10 character minimum ?

MultiView issue with validation in form


Hi all,

Currently I am working on a user control which has the following "layout":

  • the user control elements are placed inside an Update Panel
  • inside the Update Panel I have a MultiView control with 4 views:
    • first view 2 buttons to select the type of the user to create (clicking one button changes the active view to the second view, clicking the other one activates the third view)
    • second view is for the form used to create a user type
    • third view is for the form used to create the other user type
    • forth view should be used to display the confirmation message for the creation of both user types

In both forms, besides he usual textboxes I am also using validation controls to make sure the data the user inputs is correct.

However, I have a problem in case the data is invalid (the user doesn't input some mandatory field): for a very short period of time I see the * next to the mandatory field and the error in the validation summary, but immediately the active view is switched back to the first view in the MultiView control.

How can I force the control to stay on the view with the selected form?

Any ideas, suggestions or comments are welcomed!

Thank you in advance!


Catch 22 Database Connection Validation Issue w/ BIDS and Production Server


I have a rather simple SSIS package that exports data through an ODBC connection from an IBM iSeries database and copies that data to a SQL Server 2005 database.  When I was designing the application, I was able to connect to the iSeries database and store the user ID and password with my BIDS project and copy the data with out any problems.  Great!

When I finished designing and testing the project, I loaded it to the production server.  The final test was to schedule the process so that it would run each night.  I didn't realize it at the time but the password that I had stored with the project in BIDS was removed from the package and various MS documentation stated that I should create a configuration file and load the password from there.  So, I made the necessary changes to the project, adding a configuration file.  The config file is in the Miscellaneous folder within the BIDS project, however, it isn't automatically copied to the bin directory when I build the project.  I have to manually save it to the server, and then after importing the project I have to manually link to the necessary config fields.

This fixed the problem with the server, however, now I can not get BIDS to save my password with the connection string from within the designer.  This is a huge problem.  I am exporting from 21 different da

IDataErrorInfo client side validation


Is there a way for client side validation while using IDataErrorInfo?

Security Validation / Silverlight issue?

When Security Validation is turned off on a 2010 web application, the Silverlight menus break in that web app.  Why is that?  I've seen it across many farms, so I know it's an issue.

Range Validation


i have text in which i want when the user  lose the focus from the textbox...it should get error message saying please enter the number between 1 and 8.

MVC 3 Beta - PasswordFor Validation Issue


I have been working with MVC 3 Beta, and things are off to a very good start.

However, I discovered that PasswordFor() is not emitting unobtrusive validation.  I worked around it for now by using TextBoxFor(), and adding type = "password" to the attributes for the textbox.  This gives me a password field, and my unobtrusive validation is emitted.

Is this the correct forum to report MVC 3 Beta issues?



Metadata buddy class validation issue


I accidentally duplicated the thread and I found no way to delete one of them.

Please, follow the thread here: http://forums.asp.net/t/1614475.aspx




I am using asp.net MVC 2 and Entity Framework 4. I followed the directions to annotate my model classes through a buddy metadata class, so annotations are not lost when EF classes are generated.

It worked fine for a simple class, but now I am working on a more complex class, that requires regular expression and range validation for double type values.

It seems that for this class, MVC is finding the annotation to display the label (I changed the annotation and I saw it changed on my browser), but as far as the validation annotations, it is ignoring it completely.

Any idea before I try something crazy, like downloading the mvc source, and debugging the framework myself?



Input-validation-Error issue when Model has complex types



I have implemented aps.net mvc validation and it is working fine. Only issue I have "Input-validation-error" css class is not getting applied if model has complex types.

I am using my own data annotations for validation.

Any idea how to resolve  this.



Range Validation Rule

In this post I will show you one of the rule which is quite often used in applications is the Range validation, To check the range of the input user control so that user can't enter less or more then the minimum and maximum value respectively. In my previous post I have show you how to use the validation rules you can read it if you don't have any idea about the validation rules.This post is the continuity of the previous post.
Let us start with the range validation rule example. The example code for this example is the same as I have used for the previous post I have added new validation rule with the name of the RangeValidation in the ValidationRules folder, where all the validation rules are placed.In the List 1 you can see the complete class for the RangeValidation rule. Here you can see that I have three properties one for the MaximumLength and MinimumLength for checking the maximum values entered in the user input control and to check the minimum value entered by the user in the input control respectively.

Regex validation of a range of digits



I need to check if a variable is inside of a range.

E.g. I'll like to check if variable "input" of type Int32 with the value 5 is in the range from 0 to 15.

I've tried with

if (Regex.IsMatch(input.ToString(), "([0-9]|1[0-5])"))


Console.WriteLine("In the Range");


It doesn't work :-(

Can somebody help,

ThanX :-)





Active Directory Issue : Validation fails for newusers and few randon users


Hi All,

We started observing this behaviour from past couple of days. Even the AD Validation fails for the newly created users. So there are few users for whom the Active Directory authentication fails. We are not sure why it is happening. The code and configuration is not a problem since the same code works for other environment which has different domains. Has some one seen this kind of behaviour before. Infact we had a service to authenticate users so initial culprit was the service but now we have minimize the problem domain to AD. I created a simple application which JUST VALIDATES the user against the AD but still the same problem.  I am getting very generic error which does not seem to help in debugging.

Any help will be highly appreciated.

Event Type:   Information

Event Source: ASP.NET 2.0.50727.0

Event Category:       Web Event

Event ID:       1315

Date:            4/5/2011

Time:            3:35:42 PM

User:            N/A

Computer:     TRNMCS001


Event code: 4006

Event message: Membership credential verifi

IsapiModule Error 500 Issue


I am about exhausted trying to figure out this error:

HTTP Error 500.0 - Internal Server Error

Description: The page cannot be displayed because an internal server error has occurred.

Error Code: 0x8007007b

Notification: ExecuteRequestHandler

Module: IsapiModule

Requested URL: http://localhost:80/ReportServer

Physical Path: c:\Program Files\Microsoft SQL Server\MSSQL.2\Reporting Services\ReportServer

When I enable Failed Request Tracing Rules and view the log output I am supposing that the actual problem is in the 2nd call where there are 2 backslashes before the actual filename in the specified path:


CALL_ISAPI_EXTENSION DllName="C:\Windows\Microsoft.NET\Framework\v2.0.50727\\aspnet_isapi.dll"

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