MVC Data Annotation Validation Rule For Collection?

Dec 2, 2010

Is there a dataannotation validate rule for a collection based property? I have the following
<DisplayName("Category")>
<Range(1, Integer.MaxValue, ErrorMessage:="Please select a category")>
Property CategoryId As Integer
<DisplayName("Technical Services")>
Property TechnicalServices As List(Of Integer)
I'm looking for a validator that I can add to the TechnicalServices property to set a minimum for the collection size.

View 1 Replies


ADVERTISEMENT

ASP.NET MVC Model Validation With Data Annotation Attributes In .NET?

Feb 25, 2011

in the sense that MVC does not complain about my protected inner abstract Metadata class, and the model validation still works:

Partial Domain Object, generated by a tool:
Partial Public Class SampleDomainObject
Private _id As Integer

[code]....

I did this because I didn't want to have to implement actual properties with backing fields, getters, and setters in VB.NET for the Metadata class to keep the maintenance to a minimum (I'm on .NET 3.5, no auto-properties for me).What I'm worried about is that having a protected abstract inner class could be confusing to others using this domain object outside of MVC (my domain objects are part of a shared data access framework).

View 2 Replies

Architecture - Apply The Correct Data From The GUI To The Parameters For The Rule And Execute The Rule

Apr 6, 2011

I have a very simple Business Rules Engine that has only three methods. One gets all the rules for the current operation, one will retrieve a list of parameters for the rules, the last applies the rules. The rules are stored in the database as user defined functions using parameters. The client will call the BRE pass in the operation and a Lot Number and the BRE checks for any rules that apply to this operation for this Lot. The client gets a list of rules that apply (the names of the corresponding UDF's in the database) and at which step in the operation the rule applies. When the material gets to a step that has a rule, it calls BRE to get parameters for the UDF for that operation, fills in the parameters with data contained in the GUI and calls the BRE to apply the rule with this lot's specific data. Multiple lots can share the same rule that is why there are parameters for the UDF. This all works well. However, this is assuming we have a set number of rules for each lot at each operation. If the lot needs a new rule applied at this operation we have to add a new rule and corresponding UDF into the BRE database. This is not a problem, the client will now see two rules, however, it only knows how to apply the parameters for the first rule, and there is no code for applying the parameters for the second rule.

For example: Rule 1 states that only the same Lot number items can be put into a carton. So the UDF expects one parameter called LotID and one parameter called Carton ID. It runs the rule (UDF) with these parameters and checks to ensure the lots match. Now the Lot requires a second rule: Only 25 items can be packed in the carton. We create a new rule and corresponding UDF, but this rule has the CartonID and a quantity associated with it.

The GUI can handle Rule 1 because it knows how to apply the correct data from the GUI to the parameters for the Rule and execute the rule, so LotID from the GUI = LotID in the parameter name in the UDF and CartonID from the GUI = CartonID parameter name in the UDF. Now there is a new rule, the GUI sees this new rule, gets the parameters, but has no way to applying the quantity to the new parameter to execute the rule without having to change the GUI. We don't expect there to be many rule changes, however, when they do occur we don't want to have to recompile the GUI every time. Does anyone have any suggestions on how to create a class that could determine the how to apply set the correct parameters? We have thought about a table in a database that maps the parameter names in the UDF with parameter names in the GUI so when we add a new UDF we update the table with the corresponding data from the GUI. That could work but may get cumbersome and would require us to make sure that, that table is kept current. Another suggestion was to name the parameters in the UDF the same as the parameters in the GUI, but this too, would require us to maintain the names in two locations.

View 5 Replies

Enforce Validation Rule In Create Table Statement For A Coloumn

Dec 15, 2011

I want to enforce validation rule in create table statement for a coloumn. im using vb.net as front end and access as back end.

View 2 Replies

Data Annotation - Argument Not Specified For Parameter

May 29, 2012

I'm trying to pass some parameters into a data annotation, and it is rejecting my named parameter. It's the same exact syntax in Microsoft's documentation for the TableAttribute, except in the documentation they have an uppercase N, but intellisense on the parameter in VS asks for a lower case n. It looks like the constructor was updated, but the tooltip wasn't, because this is what shows up when you get the syntax prompt: And I needed to be able to specify schema. But now I've found another way to do this. Why I was trying named parameters in the first place; because this wasn't working. Apparently I missed trying this syntax, which works.

View 2 Replies

Can Store Data Annotation Error Messages In An External File

Dec 17, 2010

I am using data annotations to validation my class properties. A requirement has emerged to store the validation error messages in an external file from which they would be loaded into memory at runtime.I thought I'd be able to load a colleciton of error messages from an XML file and then set ErrorMessage:=[StringVariableHere] ... but apparently that doesn't work as you need to use a constant value.If I store the errormessages in a Resource.resx file then those error messages are compiled into the project and can't be loaded at runtime - or am I wrong?

View 1 Replies

Creating A Software That Can Annotate Pictures And Save With The Annotation?

Mar 3, 2011

creating a software that can annotate pictures (jpg)and then save the (jpg) file togerther with its annotation using VB.NET?

View 11 Replies

Understand Which Type Of Number Annotation Is Used On The Current Computer?

Jun 30, 2009

A number like 1,000,000.33 is written in another country as 1.000.000,33

which computer setting do I need to read to understand which type of number annotation is used on the current computer?

is there a way to convert those numbers in a neutral way??

View 12 Replies

Make Data Validation?

Aug 11, 2010

I have dragged across the details of a table from the data sources onto a form. So VS2008 automatically generate the BindingNavigator, DataAdapter,Dataset, ...etc. On the form I hv also placed an errorProvider and listbox, which is bound to the bindingsource. So as user clicks on the items of the listbox, the values of the textboxes changes accordingly. My question is how do I validate the values in the textboxes.

View 4 Replies

Comparing Data In A Text File With Data In A Combo Box Collection

Apr 14, 2011

i need to be able to compare data from a text file with the collection of a combo box.My algorithm currently populates the combo box with data from the text file on the form load event.I have included an update button that updates the combo box collection.[code]

View 1 Replies

Create New MS Outlook Rule VB

May 5, 2012

I'm trying to write a rule to compensate for laziness caused by program changes. Used to be, case numbers for family law cases where I work were written as follows: 12-DR-012345. Now, you can get away with 12DR12345, and the file management program accepts it.

View 1 Replies

How To Merge Two DataSets On Specified Rule

Apr 13, 2010

I'm trying to merge two datasets based on these rules:
1. With ds1 and ds2, If the Unique Key from ds1 is not found in ds2, copy it to ds2 and move to next row in the table, else, goto the next part
2. If the unique key in ds2 is found in ds1, check the DateLastEdited row.
a. If DateLastEdited in ds2 is greater then in ds1, copy the row from ds2 to ds1, else , do nothing

I'm just having trouble with the loops. Here's what I have:
Dim ds1 As DataSet = fillNetwork() 'this function fills ds1 with the dataset from a table found on a network
Dim ds2 As DataSet = fillLocal() 'this function fills ds1 with the dataset from a table found on local drive
Dim returnRows() As System.Data.DataRow = Nothing
For Each dtDs1 In ds1.Tables
[Code] .....
This bit of code is just trying to segregate the one that are in both tables from the ones that are just in one table.

View 6 Replies

Add Data Validation To A Web Form Field Using ASP.NET?

May 4, 2012

This seems like I only need a line or two of code? This is what I need to do:

Add data validation to the new phone field on the Contact Us form. We would only accept phones with the following format: 995-999-9999 Complete the contact us form so that you can submit it as an email. Send all your test emails to blah@boo.net. You can use any email account you have to send the email.

[Code]...

View 1 Replies

Add Data Validation To A Web Form Field?

Nov 5, 2010

Add data validation to the new phone field on the Contact Us form. Wewould only accept phones with the following format: 995-999-9999Complete the contact us form so that you can submit it as an email. Send all your test emails to blah@boo.net. You can use any email account you have to send the email.

View 4 Replies

ASP.NET MVC - Implement Validation When Using Data Repositories?

Jun 15, 2010

I've built a UserRepository interface to communicate with my LINQ to SQL Data layer, but I'm trying to figure out how to implement validation.

Here is what my AddUser subroutine looks like

Public Sub AddUser(ByVal about As String, ByVal birthdate As DateTime, ByVal openid As String, ByVal regionid As Integer, ByVal website As String) Implements IUserRepository.AddUser

[Code].....

View 2 Replies

Basic Validation Of Data In A Textbox?

Feb 17, 2012

I have to use basic methods to validate the data that's entered is acceptable. The chapter we are on only gets into checking if a value is =, >, < etc etc, but I want to check if a letter was entered where a number was expected, so I ended up
with this:

'Store user values
If Not IsNumeric(inputLoanAmount.Text) OrElse CDbl(inputLoanAmount.Text) < 0 _
OrElse Not Integer.TryParse(inputLoanTerm.Text, loanTerm) _[code]....

View 4 Replies

Forms :: Data Validation In Textboxes?

Dec 7, 2009

I Have four textboxes, I want textbox1 to accept only char data.I want textbox2 to accept only numeric data.I want textbox3 to accept

View 1 Replies

VS 2010 Data Validation Using TriParse?

Nov 10, 2011

I was having a little trouble using TryParse. I have 3 texts boxes that I just want to always be decimals and if false a message box will come up, but if true it will do nothing. Another thing was how can I just make it so one message box comes up because right now I have it split into 3

If Decimal.TryParse(TxtLoan.Text, decAmountInput) = False Then
MessageBox.Show("The data you enter must be positive, numeric data. Please re-enter valid date. ", "Invalid Data")

[code].....

View 6 Replies

Applying A Rule Set To Different Lines Of Text?

Apr 27, 2012

The general purpose of my application simply reads a line of text for example:

1. I have a printer issue
2. I have a software issue

I have a rule set as follows:

'Define the class 'Printer' with 14 values as a string...
Dim Printer(13) As String
'The string 'Printer' gets assigned a value, this is repeated another 13 times...
Printer(0) = "Printing"

[code]....

The code simply uses a number of keywords to detect if the issue is a 'printer', 'software', 'telephone',. or 'password' problem.I want to apply this rule set to 10 issues within the same rich text box, with the results sent to a text file. The exporting to a text file I can do, however the main issue is, i cannot read the lines individually.

View 5 Replies

Asp.net - Subdirectory URL Automatic Rewrite Rule?

Apr 25, 2012

I'm using ASP.NET 4 / VB.NET / IIS to build a web application. Folks will access the web application via a URL like so: [URL] So, for example, here is the urls for Jane Doe, John Doe, and James Doe respectively: [URL] I need to somehow pass them off (no matter what name is entered) to a default.aspx page which then pulls in the name portion of the url and uses it to perform a lookup against the database which contains info. about this particular person and displays a personalized page based on that information.

[Code]...

View 1 Replies

VS 2010 Check First Rule (not Line) In RTB?

Mar 5, 2011

Let's say I have a rtb with a few lines.

line1: (empty)
line2: (empty)
Line3: "blablablablabla"
Line4: ..... etc

How do I get/read the first, only the first line? ("blablablabla")

View 9 Replies

Data Validation On Huge Flat-file?

Jun 5, 2011

I have a huge amount of data in flat-file format that I would like to validate with Visual Basic 2010. Basically the data is a text file with 300 comma separated fields and 500,000 records.

Any tips, sample code or examples? Are any .NET classes specifically geared for data validation?

As I have different validation rules for each field (some fields are dates, some are currency, etc.) I would like to store the rules away from the code (e.g. in an SQL database table). Has anyone seen this done before?

View 1 Replies

Do Data Validation When The User Exits A Control

Jan 31, 2012

What is the best method to do data validation? I want to do data validation when the user exits a control so that he gets immediate feedback. I can use the Validating event or the Leave event for that. The problem is, that if the user doesn't know the right answer, and just wants to click the cancel button and leave the form completely, it won't let him. It continues to give him an error message until he completely deletes his answer. Very frustrating. Does anyone have a good method for doing this?

View 5 Replies

Implement Extensive Data-Validation In MVVM?

Jul 14, 2011

Possible Duplicate:How can I handle a Validation.Error in my ViewModel instead of my View's code behind?The usual examples of how to use Data-Validation in WPF usually only involves defining an error template for the control and displaying the error message in the control tooltip. What I want to do is to create a collection of all ValidationErrors, display it in an ItemsControl to the user and focus the invalid control when the user clicks on the associated (error) item in the ItemsControl.

View 2 Replies

Input Validation Using Data Type Double

Jan 24, 2010

How do you validate input when you are dealing with doubles. I have successfully gotten the message box to pop up when the user enters a number in a text field, but what if I have a text box that requests a number from the user and they enter text? This is the code, the even for btnDisplayFull works fine, but not btnDisplayRqst: [code]

View 2 Replies

Multiple Textboxes With Different Type Of Data Validation

Jun 22, 2010

I have four textboxes,
I want textbox1 to accept only char data.
I want textbox2 to accept only numeric data.
I want textbox3 to accept only alphanumeric data.
I want textbox4 to accept only bolean data.

View 2 Replies

Partial Class Custom Data Validation

Sep 29, 2011

I am testing custom data validation with partial classes. It is a Windows Form Entity Framework application .In the partial class file (time.vb) the code is:[code]What is wrong with my code? How can I handle the exception message in the main form (thrwon by the OnDataFundChanging event)?

View 3 Replies

VS 2010 Data-bound Controls Validation?

Aug 24, 2011

I'm currently working on a data entry application in VB.NET and I'm using data-bound controls by simply dragging the table from the Data Sources window onto the form. It's my first time doing this, but this will save me quite a bit of time since this table has plenty of fieldsAnyway, my problem is that when I enter an invalid value in a textbox and then delete the text it won't let me select other controls or even close the form!
For example, say I have an Age field in the DB, which is an int and I mistakenly type "," on its textbox. Then I decide I actually want to leave that field blank (considering it allows nulls) so I just delete all of the textbox's contents, after doing so, I'm not able to switch focus to another control or close the form.

View 9 Replies

Business Rule Engine - GUI To Check For Three Rules ?

Mar 30, 2011

I have a simple business rules engine that I need to write. I have looked at both Biztalk and Windows Workflow, but they are to much for what we need to do. This is a process that material will come to an operation, the GUI will check for three rules, one for the operation, one for the steps in the operation, and one for the item coming into the operation. These are the only three checks that will be done. It is possible there will be more than one rule for each check. I have a simple database set up to contain all the operations, steps and products and there is a crosstab table that links all the rules to each item. Here is an example of some rules (these are actual rules from the process):

View 5 Replies

Conceptual / Rule Implementation / String Manipulation

Dec 29, 2011

So I'm working on a software in VB.Net where I need to scrape information and process it according to rules. For example, simple string replace rules like making "Det" into "Detached" for a specific field, or a split/join rule, basic string operations. All my scraping rules are RegEx and I store them in a database in rows of rule sets for different situations.What is the best way behind creating/storing rules to manipulate text? I do not want to hardcode the rules into the software, but rather be able to add more as there will be a need for them. I want to store them in a database, but then how do I interpret them?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved