Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 12th, 2007, 01:18 AM
Friend of Wrox
 
Join Date: Apr 2004
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to Reference a Page in an External Class

I'm writing a Data Access Layer in a class that lives in the App_Code folder. I'm trying to move all my database access into that layer.

I want to write a method in that class that takes a page as a parameter, as in...
Code:
Public Class DBLayer

Public Shared Sub InsertRecord (ByRef myPage as Page)
  'Get the contents of a textbox on the page
  Dim myString as String
  myString = myPage.myTextbox.Text
End Sub

End Class
Needless to say this doesn't work. I need to be able to cast myPage as an instance of the actual page that calls the DBLayer.InsertRecord method. So if the page is called George.aspx, and the class is named George, I would write...
Code:
Public Shared Sub InsertRecord (ByRef myPage as George)
In ASP.NET 1.1, you could do this simply by declaring the page's class as Public. In 2.0, you can't do that anymore.

So I'm wondering what the way to go is. I'd rather not reference every control on the parent page using FindControl, because there are several dozen controls. The code would get pretty messy.

Thanks for your help.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Using class reference getting error rojiin ASP.NET 2.0 Basics 2 July 6th, 2007 01:53 PM
Reference Cache or Application from a class pauliehaha ASP.NET 2.0 Professional 1 April 17th, 2007 09:51 AM
Reference Page Control from Custom Class wirerider ASP.NET 2.0 Professional 6 February 1st, 2006 07:45 PM
Passing a class by reference James Diamond VB How-To 13 February 16th, 2004 06:07 AM
Reference a class within ocx shahpragnesh_p Pro VB Databases 1 August 28th, 2003 08:31 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.