473,378 Members | 1,544 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

how to pass a web app page reference (specific instance)?

ASP.NET with VB.NET using 2.0 framework

I've created a class (myClass) under App_Code specific to my web
application.

I have a method in myClass called Display:

Public Function Display(ByRef aWebPage As Web.UI.Page) As Boolean

Select Case aWebPage.Page.ToString
Case "ASP.CustomerValidation"

End Select

End Function

What I would rather do is overload the Display function using specific page
references contained in my web application.

Public Overloads Function Display(ByRef CustomerPage as ????) As Boolean
.....

Public Overloads Function Display(ByRef PaymentPage as ???) As Boolean
.....

assume I have a a CustomerPage.aspx and a PaymentPage.aspx in my web
application

How do I make direct references to this pages from the myClass.Display()
method?

Thanks, Rob.
Mar 14 '06 #1
7 1832
dont really understand what your asking. you kind of answered your own
question

Public Overloads Function Display(ByRef CustomerPage as CustomerPage)
As Boolean

Public Overloads Function Display(ByRef CustomerPage as PaymentPage) As
Boolean

You would just pass the types of those pages to the different
functions.

What code will be executed under Display()? Depending on what your
doing, you could create an abstract class/interface, and then cast pass
the pages as your interface/abstract class. This would utilize
polymorphism

Mar 14 '06 #2
The problem is I can't get myClass.Display method to identify the specific
web page reference of my web application (i.e. as CustomerPage) -- I can
only reference the generic type Web.UI.Page from the myClass.Display method.

Probably missing something simple, but don't know what.

The class (myClass) resides in my web application under the App_Code
directory but it can't see to see any of my web page references (i.e.
CustomerPage, PaymentPage). I tried to qualify it with
MyWebAppName.CustomerPage but not such reference was available in MyClass.

Rob

"dkode" <dk****@gmail.com> wrote in message
news:11*********************@p10g2000cwp.googlegro ups.com...
dont really understand what your asking. you kind of answered your own
question

Public Overloads Function Display(ByRef CustomerPage as CustomerPage)
As Boolean

Public Overloads Function Display(ByRef CustomerPage as PaymentPage) As
Boolean

You would just pass the types of those pages to the different
functions.

What code will be executed under Display()? Depending on what your
doing, you could create an abstract class/interface, and then cast pass
the pages as your interface/abstract class. This would utilize
polymorphism

Mar 14 '06 #3
what does the namespace declaration look like in CustomerPage and
PaymentPage? Are the classes and aspx pages in the same namespace? if
not, import the namespace at the top of myClass

Mar 14 '06 #4
Apparently VS 2003 supported this concept of specific web page reference
from a class within the same web app. However, it turns out that VS 2005
does NOT support this now (something to do with it being a compiled
process) -- my only options would be to put all my .aspx pages in the
App_Code dir, however, this would then drop some of the functionality I get
from other aspects of VS 2005 code behind.

Web pages in VS 2005 are setup as "Partial Class". The aspx pages and the
class is under the same web project but there is no namespace defined for
the web pages. But if you can confirm this just do this:

1. Create new web projects/solution
2. Add web page
3. Add a class -- you will have to place it in App_Code dir (VS 2005 will
be prompt you)

Now try to reference the web page from within your new class. If you find a
way to do this, please share.

Oh well, one step forward, two steps back.

Rob.

"dkode" <dk****@gmail.com> wrote in message
news:11**********************@j52g2000cwj.googlegr oups.com...
what does the namespace declaration look like in CustomerPage and
PaymentPage? Are the classes and aspx pages in the same namespace? if
not, import the namespace at the top of myClass

Mar 14 '06 #5
here is a link to the specific issue

http://msdn.microsoft.com/asp.net/re...net.asp#issue1
"dkode" <dk****@gmail.com> wrote in message
news:11**********************@j52g2000cwj.googlegr oups.com...
what does the namespace declaration look like in CustomerPage and
PaymentPage? Are the classes and aspx pages in the same namespace? if
not, import the namespace at the top of myClass

Mar 14 '06 #6
You could do like they mentioned and use an abstract base class, then
have a switch statement for each type, although this is not OOP and
even the idea of it is making me cringe :)

I'm suprised that MS would do something like this that cripples certain
features that are required to do proper OOP programming

Mar 14 '06 #7
Cost of "improved performance" I guess -- I would rather avoid thinking
about what MS do and don't do -- either road leads to frustration for me, so
I just take the good with the bad and hope there is more good than bad. So
far, VS 2005 is marginally better than VS 2003. Q3 is a long wait to fix
many of the current VS 2005 issues, but this is one of those "by design"
issues that doesn't qualify.
"dkode" <dk****@gmail.com> wrote in message
news:11*********************@j52g2000cwj.googlegro ups.com...
You could do like they mentioned and use an abstract base class, then
have a switch statement for each type, although this is not OOP and
even the idea of it is making me cringe :)

I'm suprised that MS would do something like this that cripples certain
features that are required to do proper OOP programming

Mar 14 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Casey | last post by:
Yeah, I know this question was asked by someone elselike 2 weeks ago. But I need some additional help. I have a program I'm developing, and multiple different forms will be opened. For now though,...
110
by: Mr A | last post by:
Hi! I've been thinking about passing parameteras using references instead of pointers in order to emphasize that the parameter must be an object. Exemple: void func(Objec& object); //object...
8
by: Brian F | last post by:
Exactly what the subject says. I have an ASP page that I want my C# windows application to open in Internet Explorer, and if possible have it send along a list of values from a list box. Thank you.
6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
4
by: Terry Mulvany | last post by:
I have a 'BasePage' (BasePage.cs) derived from System.Web.UI.Page that all my pages inherit from. I need to set some properties (either in the OnInit or constructor) based on a potential...
9
by: Frank Rizzo | last post by:
I've got a number of user controls on the web page. How can I pass some data to it? I don't see where the user control is instantiated in the page code-behind page. Thanks.
10
by: John Bailo | last post by:
I want to pass a SqlCommand object as a input parameter to a method. I want to pass the SqlCommand "by value" so that any updates to the original object are *not* reflected in the object within...
4
by: Jon Slaughter | last post by:
I'm reading a book on C# and it says there are 4 ways of passing types: 1. Pass value type by value 2. Pass value type by reference 3. Pass reference by value 4. Pass reference by reference. ...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.