PC Review


Reply
Thread Tools Rate Thread

Avoiding late binding

 
 
Andrew Morton
Guest
Posts: n/a
 
      1st Apr 2005
(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


 
Reply With Quote
 
 
 
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      1st Apr 2005
"Andrew Morton" <(E-Mail Removed)> 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/>

 
Reply With Quote
 
Andrew Morton
Guest
Posts: n/a
 
      1st Apr 2005
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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
>> Early binding and late binding with attachment =?Utf-8?B?Sm9uYXRoYW4=?= Microsoft Outlook VBA Programming 2 9th Jun 2006 02:24 AM
Avoiding late binding Andrew Morton Microsoft Dot NET 1 1st Apr 2005 01:05 PM
Late Binding examples of binding excel application =?Utf-8?B?SGVhdGhlck8=?= Microsoft Excel Programming 14 17th Mar 2005 08:19 AM
EARLY binding or LATE binding ? jason Microsoft Excel Programming 6 26th Feb 2004 04:57 PM
Early Binding v.s. Late Binding =?Utf-8?B?Q2hyaXMgQWRhbXM=?= Microsoft VB .NET 13 19th Jan 2004 03:47 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:09 PM.