A new feature of VB.NET 2.0 is the My namespace. The My namespace is a set of objects that are implicitly available to your applicaton and provide shortcuts to many code intensive tasks.
Listed below are the My namespace objects and their uses.
My Namespace Objects
|
Object
|
Purpose
|
|
My.Application
|
Provides properties, methods, and events related to the current application.
|
|
My.Computer
|
Provides properties for manipulating computer components such as audio, the clock, the keyboard, the file system, and so on.
|
|
My.Forms
|
Provides properties for accessing an instance of each Windows form declared in the current project.
|
|
My.Log
|
Provides a property and methods for writing event and exception information to the application's log listeners.
|
|
My.Request
|
Gets the HttpRequest object for the requested page.
|
|
My.Resources
|
Provides properties and classes for accessing the application's resources.
|
|
My.Response
|
Gets the HttpResponse object associated with the Page. This object allows you to send HTTP response data to a client and contains information about that response.
|
|
My.Settings
|
Provides properties and methods for accessing the application's settings.
|
|
My.User
|
Provides access to the information about the current user.
|
|
My.WebServices
|
Provides properties for creating and accessing a single instance of each XML Web service referenced by the current project.
|
Click here to test the script below live
<%
@
Page
Language
="VB"
%>
<
script
runat
="server">
Private
Sub
Page_Load(
ByVal
sender
As
Object
,
ByVal
e
As
EventArgs)
litOSFullName.Text =
"OS: "
&
My
.Computer.Info.OSFullName.ToString()
End
Sub
script
>
<
html
>
<
head
>
<
title
>
My Namespace Example
title
>
head
>
<
body
>
<
form
id
="Form1"
runat
="server">
<
asp
:
Literal
ID
="litOSFullName"
runat
="server"
/>
<
br
/>
form
>
body
>
html
>