Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2002-05-14
7
Medium Priority
?
539 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
6 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
Independent Software Vendors: 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

810 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