473,395 Members | 1,348 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,395 software developers and data experts.

ASP.Net 2.0 - refering to the web page class

Just loaded up ASP.Net 2.0 and found that I can't refer to a specific web
page class from another class.

For example:

Partial Public Class _Default
Inherits System.Web.UI.Page

End Class

In another class defined in tha project, I get a Not Defined error

Public Class Class2

Private _def As _Default 'this line generates the error

End Class

I'd like to be able to do this so I can implement the MVC pattern.

Must be something simple as I could not imagine that this would be a
restriction.

Regards,

Nick

Feb 9 '06 #1
3 1291
you shouldn't need this for the MVC pattern, but to reference another page,
you need reference directive in the calling page.

-- bruce (sqlwork.com)

"Nick Zdunic" <Ni********@discussions.microsoft.com> wrote in message
news:CA**********************************@microsof t.com...
Just loaded up ASP.Net 2.0 and found that I can't refer to a specific web
page class from another class.

For example:

Partial Public Class _Default
Inherits System.Web.UI.Page

End Class

In another class defined in tha project, I get a Not Defined error

Public Class Class2

Private _def As _Default 'this line generates the error

End Class

I'd like to be able to do this so I can implement the MVC pattern.

Must be something simple as I could not imagine that this would be a
restriction.

Regards,

Nick

Feb 10 '06 #2
The implementation of MVC I use, taken from profession Design Patterns in
VB.Net, does need it.

Class2 is not a page it is normal class that needs to have a reference to
webpage class _Default

"Bruce Barker" wrote:
you shouldn't need this for the MVC pattern, but to reference another page,
you need reference directive in the calling page.

-- bruce (sqlwork.com)

"Nick Zdunic" <Ni********@discussions.microsoft.com> wrote in message
news:CA**********************************@microsof t.com...
Just loaded up ASP.Net 2.0 and found that I can't refer to a specific web
page class from another class.

For example:

Partial Public Class _Default
Inherits System.Web.UI.Page

End Class

In another class defined in tha project, I get a Not Defined error

Public Class Class2

Private _def As _Default 'this line generates the error

End Class

I'd like to be able to do this so I can implement the MVC pattern.

Must be something simple as I could not imagine that this would be a
restriction.

Regards,

Nick


Feb 10 '06 #3
What we did was create a BasePage class in a sub-folder under App_Code
(you've probably realized that this is where you have to put the code
that's not part of a page).

For you it would look like this:
Public Class BasePage
Inherits System.Web.UI.Page

End Class

Then your _Default page would inherit from BasePage.
Include in BasePage all the functions you wanted to expose from
_Default.

Feb 10 '06 #4

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

Similar topics

5
by: Rajan Moorjaney | last post by:
Hello, I know that I can get the refering URL using Request.ServerVariables("HTTP_REFERER") but how can I get the URL if the page no longer exists and so is being redirected to '404 File not...
2
by: Dave | last post by:
Hello, template <class T> class weak_ptr { weak_ptr(weak_ptr const &r); }; In the code above, a parameter of type weak_ptr is declared. How is this possible? weak_ptr is not a type, it's...
1
by: Nick Zdunic | last post by:
In 1.1 it was possible to refer to a web page class from another class I've just started in v2.0 and found that this code sn't working The web page class: Partial Class _Default Inherits...
4
by: JJ | last post by:
My master page contains various graphics that are referenced from the images folder. As long as the container pages are at the same level (ie. the top level looking at the solution explorer in...
5
by: Alex Maghen | last post by:
I frequently find myself wanting to insert some basic client-side JavaScript functions in the page of an ASPX of mine. But I find it so frustrating that I have to actually contruct my JavaScript in...
21
by: glenn | last post by:
hi - Im quite new to python, wondering if anyone can help me understand something about inheritance here. In this trivial example, how could I modify the voice method of 'dog' to call the base...
1
by: Sarwan | last post by:
Hello everybody I have a solution in which there is an unmanaged MFC application. Then i added a new managed .Net Windows Form application. I was trying to refer an header file of unmanaged...
10
by: safaci2000 | last post by:
Hi all, I have a DLL that I need to access. I've managed to load it and unload it successfully. The compiler is happy no complaints or warning. I need to refer to a class object that was...
3
by: kalpana84 | last post by:
hi, Am doing coding in c#,... actually i am creating four different classes in four different . And all classes has the same namespace. What to be done If i want invoke the method of one class...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.