Tuesday, January 31, 2006

Display a Windows Form without Recreate the Object

This is a simple code to check whether a form is already created or not.
First, if the Form is nothing then we always create the object.
Second, if the form is ever created but already disposed. The objForm contains a reference but the objForm.Created is false. We also create the object.
Otherwise, we only show and activate the form without recreate the object if the form is already created.

Private objForm as myFormName

Private Sub DisplayForm()
   If IsNothing(objForm) OrElse Not (objForm.Created) Then
      objForm= New myFormName

   End If
   objForm.Show()
   objForm.Activate()

End Sub

Create ASP.Net Page Title in Web Browser

I want to introduce you how to create page Title in your web browser. I create the title first time using Visual Studio .Net 2003.

The steps are described below:
1. Add id and runat server at your asp page.
    <title id="PageTitle" runat="server"></title>
2. Add a HtmlGenericControl object in your code-behind.
    Protected PageTitle As HtmlGenericControl
3. Set the innertext for the PageTitle object in your code-behind.
    PageTitle.InnerText = "This is a new title"

These three steps will set your web browser title to a new title.

Now I migrate my application to Microsoft .Net 2.0.
Using Microsoft .Net 2.0, the steps can be written in one line:
Page.Title = "This is a new title"

The line above is a new feature in Microsoft .Net 2.0. I create my application using Visual Studio .Net 2005. This is only one enhancement in this version.

Saturday, January 28, 2006

New Visual Studio.Net 2005 Application Folders

ASP.NET recognizes certain folder names that you can use for specific types of content. The table below lists the reserved folder names and the type of files that the folders typically contain.

The content of application folders, except for the App_Themes folder, is not served in response to Web requests, but it can be accessed from application code.

1. App_Browsers : Contains browser definitions (.browser files) that ASP.NET uses to identify individual browsers and determine their capabilities.
2. App_Code : Contains source code for utility classes and business objects (for example, .cs, .vb, and .jsl files) that you want to compile as part of your application. In a dynamically compiled application, ASP.NET compiles the code in the App_Code folder on the initial request to your application. Items in this folder are then recompiled when any changes are detected.
3. App_Data : Contains application data files including MDF files, XML files, as well as other data store files. The App_Data folder is used by ASP.NET 2.0 to store an application's local database, which can be used for maintaining membership and role information.
4. App_GlobalResources : Contains resources (.resx and .resources files) that are compiled into assemblies with global scope. Resources in the App_GlobalResources folder are strongly typed and can be accessed programmatically.
5. App_LocalResources : Contains resources (.resx and .resources files) that are associated with a specific page, user control, or master page in an application.
6. App_Themes : Contains a collection of files (.skin and .css files, as well as image files and generic resources) that define the appearance of ASP.NET Web pages and controls.
7. App_WebReferences : Contains reference contract files (.wsdl files), schemas (.xsd files), and discovery document files (.disco and .discomap files) defining a Web reference for use in an application.
8. Bin : Contains compiled assemblies (.dll files) for controls, components, or other code that you want to reference in your application. Any classes represented by code in the Bin folder are automatically referenced in your application.

Configuration settings for your site are managed in a Web.config file that is located in the site's root folder. If you have files in subfolders, you can maintain separate configuration settings for those files by creating a Web.config file in that folder.