Skip to main content

Microsoft Silverlight

Answered Question Cant seem to get the Validations to workRSS Feed

(0)

lee_sl
lee_sl

Contributor

Contributor

2990 points

584 Posts

Cant seem to get the Validations to work

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

Member

20 points

5 Posts

Answered Question

Re: Cant seem to get the Validations to work

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,

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

mohnani.deepesh
mohnani....

Member

Member

251 points

48 Posts

Answered Question

Re: Cant seem to get the Validations to work

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
Microsoft
***This posting is provided "AS IS" with no warranties, and confers no rights ***

lee_sl
lee_sl

Contributor

Contributor

2990 points

584 Posts

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

Thanks Keith and mohnani

----------------------------------------------
Available for consulting in Dallas, TX
http://leeontech.wordpress.com/
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities