CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!



Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.web_forms Tags:
Item Type: NewsGroup Date Entered: 10/23/2003 5:45:51 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 14 Views: 0 Favorited: 0 Favorite
15 Items, 1 Pages 1 |< << Go >> >|
kahluakuo
Asp.Net User
2 Inherits10/23/2003 5:45:51 PM

0/0

Hi,
I have a .net page with a form template from a user control. Our pages must Inherit a corporate page class that handles html templates and it opens a database connection on every page. Now, in this user control's codebehind I inherit System.Web.UI.UserControl and I need to inherit the corporate page class becuase I need to make a call to the db in the user control. But I cant do this becuase I cant inherit more than one class. How would I get this to work?? THanks
douglas.reilly
Asp.Net User
Re: 2 Inherits10/23/2003 5:51:17 PM

0/0

YOu cannot have a user control inherit from a Page class (independent of trying multiple inheritance).

the solution is to move the implementation of the corporate stuff out of the Page class and into its own class, and the create a class that inherit from Page and another that inherits from UserControl that calls the corporate stuff appropriately.

If you are placing the user control on a page that is inherited from the corporate page class, then you can create properties in your User control and set them in the page so that the User Control has access ro what it needs.

You cannot do mulitple inheritance in .NET.
Starting with ASP.NET 2.0? Look at:
Programming Microsoft Web Forms
My Blog
kahluakuo
Asp.Net User
Re: 2 Inherits10/23/2003 5:55:50 PM

0/0

"the solution is to move the implementation of the corporate stuff out of the Page class and into its own class, and the create a class that inherit from Page and another that inherits from UserControl that calls the corporate stuff appropriately. "

I'm sorry, I dont think I follow. Assuming that I cant modify the corporate Page class, what do I do? Much thanks.
douglas.reilly
Asp.Net User
Re: 2 Inherits10/23/2003 5:59:41 PM

0/0

Well, then:

If you are placing the user control on a page that is inherited from the corporate page class, then you can create properties in your User control and set them in the page so that the User Control has access ro what it needs.

Meaning, if you are placing the UC on a page that inherits from the corporate page class, just create properties on your UC that your UC requires that your parent page can set and then the UC can use.
Starting with ASP.NET 2.0? Look at:
Programming Microsoft Web Forms
My Blog
russnem
Asp.Net User
Re: 2 Inherits10/23/2003 5:59:48 PM

0/0

You just need to shadow the Page property of your user control so that it returns your corporate page class, not just a System.Web.UI.Page.

Are you familiar with shadowing members of a base class?
kahluakuo
Asp.Net User
Re: 2 Inherits10/23/2003 6:08:45 PM

0/0

Yes,
I think I know what you are saying. But the problem is, in my UC, i have a drop down list that I populate from a database AND the only way I can get a connection to the database is to Inherit the corporate page class. and i cant do that because I inherit the system.ui.webcontrols.usercontrols. Is this what you are referring to? Sorry if I'm a lil slow to catch on.
russnem
Asp.Net User
Re: 2 Inherits10/23/2003 6:13:59 PM

0/0

If you were coding a page right now that inherited from your corporate page class (instead of this control that we're talking about), what code would you have to wire up and data bind your drop down?
kahluakuo
Asp.Net User
Re: 2 Inherits10/23/2003 6:21:26 PM

0/0

The corporate page class has a pageload and init sub that handles stuff like PostBacks and initializing db connections. So say...

--UC Codebehind--
Public MustInherit Class UCForm

Inherits CorporatePageClass
Inherits System.Web.UI.UserControl
lstCountries As System.Web.UI.WebControls.DropDownList

Sub Page_CorporatePageLoad() Handles MyBase.CorporatePageLoad
'Connect is already open, so do SELECT
Dim cmdSelectCountries

--more code--

End Sub


So thats the code. Hope that helps.
russnem
Asp.Net User
Re: 2 Inherits10/23/2003 6:23:46 PM

0/0

You say the connection is already open and ready to use - is it exposed through a property on the base page? In other words, how do you make use of this connection in your code?
kahluakuo
Asp.Net User
Re: 2 Inherits10/23/2003 6:27:11 PM

0/0

I just do

cmdSelectCount = New SqlCommand(strSQLSelectCount & strSQLCriterias, dbConn)

I dont declare dbConn in my page, so I guess its coming from the CorporatePage class.
russnem
Asp.Net User
Re: 2 Inherits10/23/2003 6:33:59 PM

0/0

Ok, then. This to me sounds like they've just declared it as Public or Protected. So this is where we might start...

In your user control, try this (not tested):


Public Shadows ReadOnly Property Page() As CorporatePageClass
Get
Return CType(Me.Page, CorporatePageClass)
End Get
End Property


Once you have that you should be able to bind your control just as you did with a slight modification:

cmdSelectCount = New SqlCommand(strSQLSelectCount & strSQLCriterias, Me.Page.dbConn)


Does THAT work?
kahluakuo
Asp.Net User
Re: 2 Inherits10/23/2003 6:44:43 PM

0/0

I get an error:

System.StackOverflowException: Exception of type System.StackOverflowException was thrown.

Any clues?
russnem
Asp.Net User
Re: 2 Inherits10/23/2003 6:47:28 PM

0/0

Yup - sorry:

Return CType(MyBase.Page, CorporatePageClass)
kahluakuo
Asp.Net User
Re: 2 Inherits10/23/2003 7:03:51 PM

0/0

whao that was awesome! thanks a bunch! i'm giong to learn into shadowing
russnem
Asp.Net User
Re: 2 Inherits10/23/2003 7:05:53 PM

0/0

My pleasure. :-)
15 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
PARLE '92, Parallel Architectures and Languages Europe: 4th International PARLE Conference, Paris, France, June 15-18, 1992, Proceedings Authors: Daniel Etiemble, Jean-Claude Syre, Pages: 984, Published: 1992
Beginning CSS: Cascading Style Sheets for Web Design Authors: Richard York, Pages: 630, Published: 2004
Process for System Architecture and Requirements Engineering Authors: Derek J. Hatley, Peter Hruschka, Imtiaz A. Pirbhai, Pages: 434, Published: 2000
International Succession Authors: Louis Garb, Union Internationale Du Notariat Latin, Pages: 684, Published: 2004
Color Atlas of Genetics: With 194 Color Plates by Jürgen Wirth Authors: Eberhard Passarge, Pages: 457, Published: 2001
IJCAI-97: Proceedings of the Fifteenth International Joint Conference on Artificial Intelligence, Nagoya, Japan, August 23-29, 1997 Authors: Martha E. Pollack, International Joint Conferences on Artificial Intelligence, Jinkō Chinō Gakkai, Japanese Society for Artificial Intelligence, Pages: 1655, Published: 1997
Thompson & Thompson Genetics in Medicine: Robert L. Nussbaum, Roderick R. McInnes, Huntington F. Willard ; with Clinical Case Studies Prepared by Cornelius F. Boerkoel, III. Authors: Robert L. Nussbaum, Roderick R. McInnes, James S. Thompson, Huntington F. Willard, Margaret Wilson Thompson, Pages: 444, Published: 2004

Web:
Bug ID: 4812240 Hangs when @inheritdoc 1) can't inherit or 2 ... doclet:tbd, Hangs when @inheritdoc 1) can't inherit or 2) inherits from super- superinterface,State: 10-Fix Delivered,Reported: 03-FEB-2003,Release Reported ...
PostgreSQL: Documentation: Manuals: PostgreSQL 8.2: Inheritance CREATE TABLE cities ( name text, population float, altitude int -- in feet ); CREATE TABLE capitals ( state char(2) ) INHERITS (cities); ...
Beta 2 inherits Beta 2 inherits. Hello !! I have a problem with Inherits in VW 2005 Express Edition Beta 2: I have a class called clsBasePage.vb ... I need to inherit this ...
CodeProject: Exploring OOPS - JavaScript Style: Part 2 ... Jun 19, 2008 ... Exploring OOPS - JavaScript Style: Part 2 - Inheritance. By mastergaurav. This article, 2nd Part in the series of 3-articles, ...
Language information and text direction 8.1.2 Inheritance of language codes. An element inherits language code information according to the following order of precedence (highest to lowest): ...
Exploring OOPS - JavaScript Style: Part 2 - Inheritance - Eduzine© In the second article of the series of "Exploring OOPS - JavaScript Style", we look at how inheritance is implemented in JavaScript. ...
C# 2.0/VS2005 inheritance reference problem - bytes Project 2 references Project 1. Project 3 references Project 2. A class in Project 2 inherits from a class in Project 1. ...
SIGCHLD inheritance proposal In step "3)", executable "B" in process "2" inherits executable "A"'s SIGCHLD signal disposition of SIG_IGN. This, according to the letter of both 1003.1 ...
InformIT: Inheritance in Java > Inheritance Basics An object of the class Student (Display 2) inherits an instance variable called name from the class Person (Display 1). For example, the following would set ...
[SQL] INHERITS and Foreign keys Dec 13, 2003 ... Code: CREATE TABLE p(id SERIAL PRIMARY KEY); CREATE TABLE a(a char(2)) INHERITS( p); CREATE TABLE b(b char(2)) INHERITS(p); ...

Videos:
Mr. Busy Inherits 2 Million Pizzolas While Mr. Greedy becomes a contestant on "The Biggest Loser".
Mephiles Inherits A Castle Part 2 Part 2 of Episode 2 of The Badnicks Show! Enjoy!
AFRICAN ZIONISM part 2/11 - Our Inheritance LAND greater than ... AFRICAN ZIONISM part 2/11 - Our Inheritance LAND greater than "State of Israel" (Genesis 15:18) READ THIS & More ETHIOPIANWORLD Videos: http ...
The AristoCats - part 2 The AristoCats part 2 of 9. The beloved, pampered housecat of a retired opera star in 1910 Paris finds herself stranded in the countryside with ...
Pinky And The Brain - Inherit The Wheeze Part 2 Brain tries to become a national hero by taking down a tobacco company.
Roseanne Inherit The Wind Part 2 (of 3) Part 2 of 3
Inheritance - 2/12 Nigeria Movie
6x03 Drew's Inheritance (1/2) Part 1.
Australia 2008 http://www.filmikz.net/ - Watch this movie fully, for free!Set in northern Australia before World War II, an English aristocrat who inherits a ...
2 Re: The Borg says you must inherit the right to speak part 2 of 3




Search This Site:










upload file to access database

asynchronous javascript in lockstep with asp

selectedindexchanged event does not fire of dropdownlist...

building yahoo map dynamically

unable to pre-populate the password text box of the login control

consume a sitemapprovider

where are the line numbers?

data lose

about movie play online

cs0246: the type or namespace name 'extractandserialize' could not be found (are you missing a using directive or an assembly reference?)

history entries in ie get mixed up

e-mail sending failure

control and default value?

how to display more than 11 items in a asp drop down list

viewstate on postback

urgent - instrumenting an application

object reference not set to an instance of an object.

how can i place a button over an image

onprerender in custom control not firing if visible=false

need a regex to capture input and option tag names

event firing is delayed too much- need help

customized file type in fileupload component?

unable to retain hyperlink

customvalidator dependent on multiple controls - solved!

carry values to next pages like in asp

dynamic controls and page life cycle

insert picture after a special word

requiredfieldvalidator question

how to implement server-side validation to checkboxlist?

counter

  Privacy | Contact Us
All Times Are GMT