ASP.NET.in.a.Nutshell.Second.Edition [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

ASP.NET.in.a.Nutshell.Second.Edition [Electronic resources] - نسخه متنی

G. andrew Duthie; matthew Macdonald

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید








13.2 Properties Reference


Count

Integer = Application.Count

Returns an integer containing the number of items
currently in the Application collection. The Count member is derived
from the ICollection interface, which is implemented by the
HttpApplicationState class.

Parameter


Integer



An Integer variable that will receive the Count property value.



Example


The example adds two values to the Application collection, displays
the count of items in the Application collection, and then uses the
Count property as a looping control value to display each item:

Sub Page_Load( )
Application.Clear( )
Application("foo") = "Hello, "
Application("bar") = "World!"
Message.Text = "The Application collection contains " & _
Application.Count & " items: "
Dim I as Integer
For I = 0 To Application.Count - 1
Message.Text &= Application(I)
Next
End Sub

Notes


The Count property is new for ASP.NET. In addition to using the Count
property for looping through the Application collection, you can use
the property to keep track of how many items the Application stores
at any given time. For example, you could write this information to a
log for later review.

Item

Object = Application.Item(ByVal name As String)
Application.Item(ByVal name As String) = Object
Object
= Application.Item(ByVal index As Integer)
Application.Item(ByVal index As Integer) = Object

Returns or sets an Object associated with a
particular name or index.

Parameters


Object



A variable of any type (since all .NET types are ultimately derived
from object) that will receive or set the item''''''''s
value.


name



A string argument containing the text key to apply to the item (or by
which to retrieve the item).


index



An integer argument containing the index of the item whose value will
be retrieved or modified.



Example


The example sets the values of two items in the Application
collection. If these items do not already exist in the collection,
they will be added. The example then displays the two values.

Sub Page_Load( )
Application.Clear( )
Application.Item("foo") = "foo"
Application.Item("foo2") = "foo2"
Message.Text = Application.Item("foo") & "<br/>"
Message.Text &= Application.Item(1)
End Sub

Notes


The Item property is accessed implicitly when using the syntax:

Application("foo") = "foo"

This syntax is often seen in classic ASP code. Explicitly referencing
the Item property is not required, but listing it may make your code
more readable and understandable than accessing it implicitly.

Note that an index may be used as an argument only when modifying a
value, not when creating a new item, and the index must be less than
the number of items in the Application collection, or an exception
will be thrown.

/ 873