Solved

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

Posted on 2002-05-14
7
517 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
asp syntax 3 67
Help with query 3 37
SP inserts data with order number, then push the rest one order up 11 17
SP result not being displayed 5 40
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…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

749 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