Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
I use Inheritance and functions for removing redundancy in code.Now, How to inherit the data members of a class in one aspx page to another page without public access specifier?Because making it public is like exposing the code and data wont be encapsulated?
Posted
Comments
Sergey Alexandrovich Kryukov 28-Sep-13 3:22am    
Are you serious? Do you think that public will expose something and private will not, really? Exposed where, to whom?
—SA

1 solution

I'm not sure that what you are asking for is exactly what you want - but you are right, it is bad practice to expose fields directly - you should encapsulate them in properties and make those public instead.

But I suspect that won't help you too much with ASPX pages - since the previous page doesn't really exist any more when the new page is displayed, it's going to be difficult to pick up it's properties! What I would suggest is storing the page values in the Session and accessing them from the new page that way: Session MSDN[^]
 
Share this answer
 
Comments
SubhamSoni123 28-Sep-13 5:06am    
I have a set of generic routines in a aspx.cs page for functions that are common to all the pages in the website.Now how to access these functions in various web pages(espically through inheritance (without public)? I don't want to use sessions because session is not permanent.
OriginalGriff 28-Sep-13 5:10am    
Put them in your App_Code folder
SubhamSoni123 28-Sep-13 5:18am    
Then will I be able to inherit and call the member functions

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900