Print Page | Close Window

Validation on TextBox

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2117
Printed Date: 13-May-2026 at 12:56am


Topic: Validation on TextBox
Posted By: bala
Subject: Validation on TextBox
Date Posted: 02-Sep-2010 at 11:11am
Hi
 
I am inserting data after entering on TextBox
 
I want to validiate that text box...
 
How can I do with DevForce.?
 
I am using Devforce200V 6.0.4.0 With Silverlight
 
 
Waiting for help



Replies:
Posted By: DenisK
Date Posted: 06-Sep-2010 at 4:16pm
Hi Bala;

You just need to bind the TextBox to the Entity's property and set NotifyOnValidationError=true. 

For example, using our NorthwindIB Database example, to bind a TextBox to the Employee.City property, the XAML file would look like this:

Text="{Binding City, Mode=TwoWay, NotifyOnValidationError=true}"

Hope this helps.

Denis


Posted By: bala
Date Posted: 08-Sep-2010 at 7:30am
Hi

I am using master details method I am showing data on grid  and after selecting a grid
his details showing on textbox.

Now i want to update data and I want validation on it. and want to fire proper error message too.

Mention code is not fireing any message.

Thanks


Posted By: DenisK
Date Posted: 08-Sep-2010 at 2:57pm
Bala;

How are you binding your UI control and Data Context?


Posted By: bala
Date Posted: 09-Sep-2010 at 4:28am
Hi Denisk

This is how I am getting records on Datagrid

public ObservableCollection<STUDENT> Students { get; private set; }
             var query = _mgr.STUDENTs;
              query.ExecuteAsync(op => { op.Results.ForEach(Students.Add);}, null);

Like this I am showing details with Clicking on Data grid
private void StudentGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (StudentGrid.SelectedItem == null)
            {
                return;
            }
            else
            {
              StudentSorders   aa = (StudentSorders)StudentGrid.SelectedItem;
                _id = aa.ID;
               txtName.Text = aa.NOME;
            }
        }
Here after diplaying record on txtbox i am doing add/delete/ update operation and this time
i need validation.

private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
                    STUDENT stud = Students.Where(t => t.ID == Convert.ToDecimal(_id)).Single();
                    stud.NAME = txtName.Text;
                    StudentGrid.ItemsSource = Students;
                    _mgr.SaveChangesAsync();
        }

Thanks


Posted By: DenisK
Date Posted: 10-Sep-2010 at 10:55am
Have you implemented an IVerifierProvider interface anywhere inside your class?


Posted By: bala
Date Posted: 10-Sep-2010 at 10:58am
No..
I did not implemented any manual code


Posted By: DenisK
Date Posted: 10-Sep-2010 at 11:01am
I see. There is a section on our Wiki that describes how to implement Data Verification with DevForce. Here is the link

http://drc.ideablade.com/xwiki/bin/view/Documentation/ValidationThroughVerification#x_footnote_ref_1 - http://drc.ideablade.com/xwiki/bin/view/Documentation/ValidationThroughVerification#x_footnote_ref_1

That should help you get started.


Posted By: bala
Date Posted: 10-Sep-2010 at 11:10am
I already been went thru this page
This validation work only on Data form or grid...
How can I populate error on text box.

Thanks


Posted By: DenisK
Date Posted: 10-Sep-2010 at 2:36pm
I've created a simple solution that should help you get started. Please click the link below to download.

http://wikisend.com/download/445970/SilverlightApplication1.zip


Posted By: bala
Date Posted: 13-Sep-2010 at 4:33am
Hey Denisk

Thanks for your sharing but this file is corrupted and not able to open in my side
would you like to share again..


Thanks


Posted By: DenisK
Date Posted: 13-Sep-2010 at 12:56pm
Please try again with this link:

http://wikisend.com/download/867508/SilverlightApplication1.zip


Posted By: bala
Date Posted: 13-Sep-2010 at 1:52pm
Hi
Thanks example looking cool
I am try to running but I have one error

 public class NoNumberVerifier : PropertyValueVerifier
            {

                public NoNumberVerifier(Type pType, string propertyName, string displayName = null, bool? shouldTreatEmptyStringAsNull = null)
                    : base(new PropertyValueVerifierArgs(pType, propertyName, false, displayName, shouldTreatEmptyStringAsNull))// error line
                {

           
             

            }

Error    1    'IdeaBlade.Validation.PropertyValueVerifierArgs' does not contain a constructor that takes 5 arguments    C:\Users\vend\Documents\Visual Studio 2010\Projects\DevF\ValidDensk\ValidDenskWeb\Student.cs    38    28    ValidDenskWeb




Posted By: DenisK
Date Posted: 13-Sep-2010 at 2:46pm
Please update to the latest 6.0.5 version.


Posted By: bala
Date Posted: 14-Sep-2010 at 9:11am
HI Denisk

I could not found any upgrade version of Devforce.
Where I can find new version?

Thanks


Posted By: DenisK
Date Posted: 14-Sep-2010 at 10:29am
If you go to our website, the new version should be up there under the product page.


Posted By: bala
Date Posted: 14-Sep-2010 at 11:25am
Hi Densk

 private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            STUDENT stud = new STUDENT();
            stud.NAME = txtName.Text;
            stud.PHONE = Convert.ToInt64(txtPhone.Text);
            mgr.AddEntity(stud);
            mgr.SaveChangesAsync();

           
        }

Now this my code for save but How to fire that validation
i want make sure Name can not be empty and Phone no should be Number..
And want to show proper error message.



Posted By: DenisK
Date Posted: 14-Sep-2010 at 3:25pm
You need to implement a class that implements an IVerifierProvider interface. Please take a look at the solution I sent you.


Posted By: bala
Date Posted: 15-Sep-2010 at 9:05am
Hi Densk

I look out your solution and try to solve problem
I am sending my solution would you check out where I am doing mistek

uploads/896/valid.zip - uploads/896/valid.zip

Thanks



Print Page | Close Window