Solved

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

Posted on 2002-05-14
7
504 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
Comment Utility
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
Comment Utility
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
Comment Utility
I am not a VB programmer... Will C# example do?
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

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

Accepted Solution

by:
haritha30 earned 0 total points
Comment Utility
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
Comment Utility
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
This video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

10 Experts available now in Live!

Get 1:1 Help Now