11. Resources
11.1 Using resources
Using .NET resource files is very easy with SASP, the system is copied from Castle MonoRail. You specify the resource files you want to use inside a control by using attributes. A ResourceAttribute? consists of a Bag name and a resource file specification. The actual resource file is then loaded and put in the Bag between the PreInitialize? and Initialize method of the control.
This means that if the culture info is set correctly after the PreInitialize? event, the correct culture specific resource files will be loaded. Once loaded, the resource files are present in the Bag, and can be used in the view files.
[Resource("Text", "SASP.WebDemo.Resources.Messages")]
public class Resources: DemoPage
{
...
}
In the view file:
$Text.Player.Name<br /> $Text.Player.Email
Example: See demo site 'Text Resources'
11.2 Resource inheritance
Specified resources are inherited from parent controls. It is also possible to specify multiple resource attributes per class. If you specify a resource in a child class with a Bag key that was already set in a parent class, the new - child - specification will still take priority. This way it is possible to override resources in child controls.
This is in-line with the normal control and Bag behavior.
