Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

Cant seem to get the Validations to work RSS

3 replies

Last post Mar 19, 2009 07:07 PM by lee_sl

(0)
  • lee_sl

    lee_sl

    Contributor

    4222 Points

    864 Posts

    Cant seem to get the Validations to work

    Mar 19, 2009 02:07 PM | LINK

    I have the following, the datagrid is populated. instead of showing the validation errors, when I run the app, it throws a runtime error with the description I have given. not sure what I am doing wrong. I can see the validations have propagated to client side

    Thanks

    <riaControls:DomainDataSource x:Name="source" LoadSize="30" LoadMethodName="LoadCustomers" AutoLoad="True">

    <riaControls:DomainDataSource.DomainContext>

    <domain:NorthwindContext />

    </riaControls:DomainDataSource.DomainContext>

    </riaControls:DomainDataSource>

     

    <StackPanel>

    <dataControls:DataPager PageSize="10" Source="{Binding Data, ElementName=source}" />

    <data:DataGrid x:Name="datagrid1" ItemsSource="{Binding ElementName=source, Path=Data }" AutoGenerateColumns="false" >

    <data:DataGrid.Columns>

    <data:DataGridTextColumn Header="Customer ID" Binding="{Binding CustomerID}"/>

    <data:DataGridTextColumn Header="CompanyName" Binding="{Binding Path=CompanyName}"/>

    <data:DataGridTextColumn Header="Contact Name" Binding="{Binding ContactName}"/>

    <data:DataGridTextColumn Header="Contact Title" Binding="{Binding ContactTitle}"/>

    </data:DataGrid.Columns>

    </data:DataGrid>

    and the metadata class has properties decorated  like this

    [Required(ErrorMessage = "CompanyName is required!!!!!!!!!!!")]

    public string CompanyName;

    [Required]

    public string ContactName;

    [Required]

    public string ContactTitle;

    public string Country;

    [Required]

    [StringLength(5, MinimumLength=5)]

    public string CustomerID;

     

    ----------------------------------------------
    Available for consulting in Dallas, TX
    http://leeontech.wordpress.com/
  • Keith Jones

    Keith Jones

    Member

    20 Points

    5 Posts

    Re: Cant seem to get the Validations to work

    Mar 19, 2009 06:03 PM | LINK

    Hi Lee,

    Silverlight 3 uses exceptions to notify the controls when validation has failed and these appear as user-unhandled exceptions when debugging. The exception you are seeing is likely expected. If you continue past the exception(s) or run your application without debugging, you should see the validation visuals. If not, please reply with the exception message and stack.

    Thanks,

    Exception Validation

    Keith Jones
    Microsoft
    ***This posting is provided "AS IS" with no warranties, and confers no rights ***
  • mohnani.deepesh

    mohnani.deepesh

    Member

    677 Points

    137 Posts

    Microsoft

    Re: Cant seem to get the Validations to work

    Mar 19, 2009 06:04 PM | LINK

    Hi Lee,

    Are you running the app in Debug mode, your application will continue if you hit F5. Alternatively, you can run the application by pressing CTRL+F5. Also ensure that the VS is not configured to throw when an exception is encountered.

    Thanks

    Deepesh

    Deepesh Mohnani [MSFT]
    Program Manager
    twitter:@deepeshm
    blog: http://blogs.msdn.com/deepm

    ***This posting is provided "AS IS" with no warranties, and confers no rights ***
  • lee_sl

    lee_sl

    Contributor

    4222 Points

    864 Posts

    Re: Re: Cant seem to get the Validations to work

    Mar 19, 2009 07:07 PM | LINK

    Thanks Keith and mohnani

    ----------------------------------------------
    Available for consulting in Dallas, TX
    http://leeontech.wordpress.com/