|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Avoiding late bindingI 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
Show quote
Hide quote
"Andrew Morton" <a**@in-press.co.uk.invalid> schrieb: If you want to use 'Option Strict On', you will have to do a type cast:> 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) \\\ 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/> Herfried K. Wagner [MVP] wrote:
> If you want to use 'Option Strict On', you will have to do a type Aha! Now it is clear. Thank you.> cast: > \\\ > DirectCast(Session("basket"), BasketCentral).AddToBasket(...) > /// Andrew
Hashtable question
Simple LookupAccountName (working) guidelines for developing an application Form question (Re-usuable code) copying data from MS-SQL to MS-Access using VB.Net How do you protect from pirating? SQL Error Object variable or With block variable not set. Anyone know what could cause the following error messages? Print information when ANY control is used |
|||||||||||||||||||||||