By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,887 Members | 1,222 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,887 IT Pros & Developers. It's quick & easy.

Avoiding late binding

P: n/a
(First posted to microsoft.public.dotnet.general by mistake.)

I don't know the correct terminology, but I'm sure there's a better way to
do the following with .aspx pages:-

In global.asax, I create an instance of an entity (basketCentral.vb) which
has subroutines, functions and variables which I want to access from any
page:-

Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
Dim basket As NS.basketCentral = New NS.basketCentral
Session("basket") = basket
End Sub

Then to use a public function in it, I use, for example,

userID=Session("basket").logon(username, passwd)

or for a public subroutine,

Session("basket").addToBasket(shopitem)

It works, but is this the "correct" way of doing it? VS.NET prompts with
GetType as soon as I've typed the dot after Session("basket"), which leads
me to think I'm missing something and causing it to use late binding.

Andrew
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Andrew Morton" <ak*@in-press.co.uk.invalid> schrieb:
In global.asax, I create an instance of an entity (basketCentral.vb) which
has subroutines, functions and variables which I want to access from any
page:-

Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
Dim basket As NS.basketCentral = New NS.basketCentral
Session("basket") = basket
End Sub

Then to use a public function in it, I use, for example,

userID=Session("basket").logon(username, passwd)

or for a public subroutine,

Session("basket").addToBasket(shopitem)


If you want to use 'Option Strict On', you will have to do a type cast:

\\\
DirectCast(Session("basket"), BasketCentral).AddToBasket(...)
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2

P: n/a
Herfried K. Wagner [MVP] wrote:
If you want to use 'Option Strict On', you will have to do a type
cast:
\\\
DirectCast(Session("basket"), BasketCentral).AddToBasket(...)
///


Aha! Now it is clear. Thank you.

Andrew
Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.