QA

IOTA^_^    

Sams Teach Yourself ASP.NET in 21 Days, Second Edition
By Chris Payne
Table of Contents
Day 19.  Separating Code from Content


Q&A

Q1:

Can I change my default primary language for my browser?

A1:

You bet! Go to Start, Settings, Control Panel, Internet Options. On the window that pops up, you should see a Languages button. Click it to modify the primary language for your browser. With the new window that pops up, you can add new languages, remove old ones, and change the priority for each.

Q2:

Can I use resource files with compiled code, such as business objects? Can I compile my resource files?

A2:

Absolutely on both counts! Using resource files with business objects can be accomplished in two ways: compile the resource files along with the business object, or leave them as separate .resources files. In the latter case, you can use them exactly as you have done today. In the former case, you'll have to change your code slightly.

The CreateFileBasedResourceManager method won't work when the resource files are compiled. Instead, you have to specify the assembly that contains the compiled resource files, with the following ResourceManager constructor:

 dim objRM as New ResourceManager("prefix", System.Reflection. _    Assembly.GetExecutingAssembly(), Nothing) 

The first and third parameters are the same as for the CreateFileBasedResourceManager method. The second parameter, System.Reflection.Assembly.GetExecutingAssembly, returns an Assembly object that represents the assembly that the code is executing from. ASP.NET then knows where to look for the resource files, and you can retrieve values from them the same way as before.

Resource files can be compiled the same way as VB.NET or C# files, with the vbc.exe or csc.exe program. Compiled files that contain only resource files are known as satellite assemblies. Refer to the .NET Framework SDK documentation for more information, or check out Sams Teach Yourself .NET Windows Forms in 21 Days for information on localizing non-Web applications.


    IOTA^_^    
    Top


    Sams Teach Yourself ASP. NET in 21 Days
    Sams Teach Yourself ASP.NET in 21 Days (2nd Edition)
    ISBN: 0672324458
    EAN: 2147483647
    Year: 2003
    Pages: 307
    Authors: Chris Payne

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net