Solved

How to Inherit same base class in .aspx and .ascx file

Posted on 2002-05-14
7
506 Views
Last Modified: 2012-06-21
To Inherit a base class in a page file, ie .aspx I have to include "Inherits Page" statement in the .vb file. If I have to inherit the class in an UserContol file, ie .ascx then I have to include the "Inherits UserControl" statement. Now my problem is I want to use the same .vb file in both .aspx and .ascx files. I cant use both the Inherit statements in same file. What shd I do to Inherit same class in .aspx and .ascx file.
0
Comment
Question by:haritha30
  • 3
  • 2
7 Comments
 
LVL 23

Expert Comment

by:naveenkohli
ID: 7008583
Codebehind implementation for PAge inherits from Page class whereas ASCX types inherit from UserCOntrol class. They are two different classes and provide different set of functionality. You can't use the same codebehind for both. One thing you can do is that create another class that has the common functionlity and contain instance of that class object in your Page as well as UserCOntrol.
0
 

Author Comment

by:haritha30
ID: 7010343
Can You please explain me with an example. I have a function,
Function text() As String
Dim a As String
a="This is a sample"
Return a
End Function
Now I wld like to call this same function in both ASCX and ASPX without having 2 base classes or .vb files.
Thanks
0
 
LVL 23

Expert Comment

by:naveenkohli
ID: 7010436
I am not a VB programmer... Will C# example do?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:haritha30
ID: 7013041
Yes thats enough. But Please inherit from the .cs file, not from assembly code.
Thanks
0
 

Accepted Solution

by:
haritha30 earned 0 total points
ID: 7015535
Thanks Naveen. I have found the answer. By using Namespace I have solved the problem. Now I can inherit the same class file from ASPX and ASCX file.
0
 
LVL 15

Expert Comment

by:gladxml
ID: 8803318
No comment has been added lately and it seems that this question have been abandoned. So it's time to clean up this TA.

I will leave a recommendation in the Cleanup topic area that this question or invite a Moderator to close this question if there's no reply from you after seven days.

In the absence of responses, I will recommend the following:

Question PAQ'd and pts refunded

** PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER **


Just trying to help for the cleanup...
gladxml
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Leverage browser caching 2 55
ASP Classic - Load test 2 45
API not working 33 56
Issues with Insert statement 12 14
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now