Skip to main content

Posts

Showing posts from October, 2007

ASP.NET Inline Code Syntax Reference

Rendering Code Syntax: <% %> and <%= %> Code enclosed by <% ... %> is just executed, while expressions that include an equal sign, <%= ... %>, are evaluated and the result is emitted as content. Data Binding Syntax: <%# %> Code located within a <%# %> code block is only executed when the DataBind method of its parent control container is invoked. Expression Syntax: <%$ ... %> ASP.NET 2.0 adds a new declarative expression syntax for substituting values into a page before the page is parsed. This is useful for substituting connection string values or application settings defined in a Web.config file for server control property values. It can also be used to substitute values from a resource file for localization.

Using resource file in VSTO 2005 project

VSTO 2005 have default resource file in MyProject folder. If you right click the project in VSTO 2005 and choose properties, you will see project properties window. In the properties window, there is a tab called Resources. You can add default resources, such as images, strings and icons. For the string of different culture, you have to add new resource file into the project. The resource file name follows the format of Resources. language-culture .resx. For example, the resource file for Canadian French is Resources.fr-CA.resx. You add the new resource file by right click the project and choose Add -> New Item.... In the Add New Item dialog, choose Resources File. In the file name box, enter the proper file name as described above, then click OK. You can then add culture specific resources into the newly created resource file.

.NET Generic Constraints Syntax

Generic supports four types of constraints: Interface: Allow only types that implement specific interfaces to use your generic Base class: Allow only types that is or inherited form specific base class to use your generic Constructor: Allow only types that implement specific constructors to use your generic Reference or value type: Limit the types to use your generic either reference type or value type Examples for these constraints: Interface: T must implement IComparable interface public class MyGenericClass where T: IComparable Base class: T must be or inherited from MyBaseClass public class MyGenericClass where T: MyBaseClass Constructor: T must have at least the default constructor available public class MyGenericClass where T: new () Reference or value type: T must be a reference type public class MyGenericClass where T: class Reference or value type: T must be a value type public class MyGenericClass where T: struct