Solved

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

Posted on 2002-05-14
7
512 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Dreamweaver server behavior gone 6 147
UTC (timezone) without using an API 16 50
Html value of radio 14 28
IIS 7 and executing pages using localhost 16 13
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
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/…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

861 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