Re: Using Page Object in VB Class File

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Alex Papadimoulis (alexRemovePi_at_pa3.14padimoulis.com)
Date: 06/17/04


Date: Thu, 17 Jun 2004 11:33:22 -0400

John,

No reason to recommend against modules. If you look at the compliation, a
Module is created as a public singleton class with all methods static
(shared). Modules are therefore OO. Avoiding them because at one point they
were pre-OO is like avoiding methods from the Microsoft.Visualbasic
namespace (such as Left()) -- it really weakens your toolset as a VB
programmer for no reason.

-- 
Alex Papadimoulis
http://weblogs.asp.net/Alex_Papadimoulis
"John Saunders" <johnwsaundersiii@notcoldmail.com> wrote in message
news:ORdZBT$TEHA.4064@TK2MSFTNGP11.phx.gbl...
> "Alex Papadimoulis" <alexRemovePi@pa3.14padimoulis.com> wrote in message
> news:%23mR6OI%23TEHA.384@TK2MSFTNGP10.phx.gbl...
> > Bijoy,
> >
> > > - How would I "include" this class in each aspx page?
> > Just create a module in your project. It will be in the assembly, and
> > automatically "included" (accessible) from all your pages.
>
> I personally recommend against modules, which are a pre-OO feature.
Instead,
> go ahead and create a Public class with Public Shared subs and/or
Functions.
>
> > > - How would I call the functions?
> > MyModule.MyFunction( arg1, arg2 )
>
> MyClass.MyFunction(arg1, arg2)
>
> > > - One of my functions does a "Page.FindControl". How can I make the
Page
> > > object accessible within the class file
> > Function MyFunction( pg as Page ) As String
> >   Dim ctrl as Control = pg.FindControl("Blah")
> >   If ctrl Is Nothing Then Return "Where Is It" Else Return "Found It"
> > End Sub
>
> Pretty good, but if you make the signature be:
>
> Function MyFunction(ctl as Control)
>
> then you'll be able to handle cases where you don't want to search the
whole
> page.
> -- 
> John Saunders
> johnwsaundersiii at hotmail
>
>


Relevant Pages

  • Re: Opinion wanted
    ... the details including the nature of my own app (which you mischaraterized ... correct the current control (provided that control is invalid but invalid ... causes you to validate controls that have already been ... largely discreditted for good reason and has very little use these days. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Niggling away at the edges (related to Homemade bullet proof vest)
    ... The earliest version of this niggling away issue that comes to my ... traffic law includes things such as issuing DUI ... rather than driving, because they maintained control of their keys, thus ... busted for DUI for just this reason, and never drove an inch after his ...
    (rec.arts.sf.composition)
  • Re: Welcome to the New World Order. Show your arm please
    ... > even if it's Americans who die. ... work and contribute to society will not be able to because they will by ... always a damned good reason why they do. ... >> in control know that it´s you behind the screen. ...
    (alt.politics)
  • Re: Pletnev arrested
    ... While it is very clear that your church can't even control the sexual ... you just see red and any small amounts of reason you ... 'stopping' the warming is clearly beyond human ability. ... it's politics, and I reserve the right to be skeptical. ...
    (rec.music.classical.recordings)
  • Re: Pletnev arrested
    ... While it is very clear that your church can't even control the sexual ... you just see red and any small amounts of reason you ... In that case, 'stopping' the warming is ... science, it's politics, and I reserve the right to be skeptical. ...
    (rec.music.classical.recordings)