Hi there,
does anybody know, how to create a class, which is can be inherited by both
aspx (System.Web.UI.Page) as well as by ascx (System.Web.UI.UserControl)
classes.
I have the bunch of same methods, which I want to reuse in both ascx and
aspx classes. Any idea how to do it?
Thanks for all your hints. 4 2475
Good suggestions. Alternatively, if for whatever reason it doesn't suit you,
you can make just a class library with static functions that will get the
reference to the control as a parameter.
Eliyahu
"Kevin Spencer" <ks******@takempis.com> wrote in message
news:uD**************@tk2msftngp13.phx.gbl... Create a class that inherits System.Web.UI.Page, or System.Web.UI.UserControl, add whatever code to it that you need to be global to all Pages/UserControls, and inherit that class in your Pages/UserControls.
-- HTH, Kevin Spencer .Net Developer Microsoft MVP Big things are made up of lots of little things.
"Vladimír Kolesnik" <ko******@seznam.cz> wrote in message news:eI**************@tk2msftngp13.phx.gbl... Hi there, does anybody know, how to create a class, which is can be inherited by both aspx (System.Web.UI.Page) as well as by ascx (System.Web.UI.UserControl) classes. I have the bunch of same methods, which I want to reuse in both ascx and aspx classes. Any idea how to do it? Thanks for all your hints.
The solution you described I already knew, thanks anyway. Maybe I was not
clear enough describing the problem, I have class MyWebPage derived from
System.Web.UI.Page (aspx), where I have often used methods for example for
dealing with database connection etc. All aspx pages I derive from
MyWebPage, everything is fine. The problem is when I have ascx class
derived from System.Web.UI.UserControl and I want to use methods to get
connection to the database and some other methods that are placed in the
MyWebPage class. Do I have to make a class similar as MyWebPage just
inherited from System.Web.UI.UserControl, for example MyUserControl to be
able use these methods for all ascx classes? I think there should be a way
to pass the problem having same methods defined in two classes.
"Kevin Spencer" <ks******@takempis.com> píše v diskusním příspěvku
news:uD**************@tk2msftngp13.phx.gbl... Create a class that inherits System.Web.UI.Page, or System.Web.UI.UserControl, add whatever code to it that you need to be global to all Pages/UserControls, and inherit that class in your Pages/UserControls.
-- HTH, Kevin Spencer .Net Developer Microsoft MVP Big things are made up of lots of little things.
"Vladimír Kolesnik" <ko******@seznam.cz> wrote in message news:eI**************@tk2msftngp13.phx.gbl... Hi there, does anybody know, how to create a class, which is can be inherited by both aspx (System.Web.UI.Page) as well as by ascx (System.Web.UI.UserControl) classes. I have the bunch of same methods, which I want to reuse in both ascx and aspx classes. Any idea how to do it? Thanks for all your hints.
Well, you can't inherit from more than one base class, so that's not a
possibility. You could certainly implement an Interface, which would require
both classes to implement the same properties/methods defined in the
Interace. You could create a class which has all the shared functionality,
and include that class as a property of both base classes.
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"Vladimír Kolesnik" <ko******@seznam.cz> wrote in message
news:#b**************@TK2MSFTNGP09.phx.gbl... The solution you described I already knew, thanks anyway. Maybe I was not clear enough describing the problem, I have class MyWebPage derived from System.Web.UI.Page (aspx), where I have often used methods for example for dealing with database connection etc. All aspx pages I derive from MyWebPage, everything is fine. The problem is when I have ascx class derived from System.Web.UI.UserControl and I want to use methods to get connection to the database and some other methods that are placed in the MyWebPage class. Do I have to make a class similar as MyWebPage just inherited from System.Web.UI.UserControl, for example MyUserControl to be able use these methods for all ascx classes? I think there should be a way to pass the problem having same methods defined in two classes. "Kevin Spencer" <ks******@takempis.com> píše v diskusním příspěvku news:uD**************@tk2msftngp13.phx.gbl... Create a class that inherits System.Web.UI.Page, or System.Web.UI.UserControl, add whatever code to it that you need to be global to all Pages/UserControls, and inherit that class in your Pages/UserControls.
-- HTH, Kevin Spencer .Net Developer Microsoft MVP Big things are made up of lots of little things.
"Vladimír Kolesnik" <ko******@seznam.cz> wrote in message news:eI**************@tk2msftngp13.phx.gbl... Hi there, does anybody know, how to create a class, which is can be inherited by both aspx (System.Web.UI.Page) as well as by ascx
(System.Web.UI.UserControl) classes. I have the bunch of same methods, which I want to reuse in both ascx
and aspx classes. Any idea how to do it? Thanks for all your hints.
Thanks a lot. Your advice was exactly what I need.
"Kevin Spencer" <ks******@takempis.com> píše v diskusním příspěvku
news:uU*************@TK2MSFTNGP10.phx.gbl... Well, you can't inherit from more than one base class, so that's not a possibility. You could certainly implement an Interface, which would
require both classes to implement the same properties/methods defined in the Interace. You could create a class which has all the shared functionality, and include that class as a property of both base classes.
-- HTH, Kevin Spencer .Net Developer Microsoft MVP Big things are made up of lots of little things.
"Vladimír Kolesnik" <ko******@seznam.cz> wrote in message news:#b**************@TK2MSFTNGP09.phx.gbl... The solution you described I already knew, thanks anyway. Maybe I was
not clear enough describing the problem, I have class MyWebPage derived from System.Web.UI.Page (aspx), where I have often used methods for example
for dealing with database connection etc. All aspx pages I derive from MyWebPage, everything is fine. The problem is when I have ascx class derived from System.Web.UI.UserControl and I want to use methods to get connection to the database and some other methods that are placed in the MyWebPage class. Do I have to make a class similar as MyWebPage just inherited from System.Web.UI.UserControl, for example MyUserControl to
be able use these methods for all ascx classes? I think there should be a
way to pass the problem having same methods defined in two classes. "Kevin Spencer" <ks******@takempis.com> píše v diskusním příspěvku news:uD**************@tk2msftngp13.phx.gbl... Create a class that inherits System.Web.UI.Page, or System.Web.UI.UserControl, add whatever code to it that you need to be global to all Pages/UserControls, and inherit that class in your Pages/UserControls.
-- HTH, Kevin Spencer .Net Developer Microsoft MVP Big things are made up of lots of little things.
"Vladimír Kolesnik" <ko******@seznam.cz> wrote in message news:eI**************@tk2msftngp13.phx.gbl... > Hi there, > does anybody know, how to create a class, which is can be inherited
by both > aspx (System.Web.UI.Page) as well as by ascx (System.Web.UI.UserControl) > classes. > I have the bunch of same methods, which I want to reuse in both ascx and > aspx classes. Any idea how to do it? > Thanks for all your hints. > > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: richardlane |
last post by:
Hi, basic question here - I'm struggling with the transfer from asp to
asp.net a bit, especially in seeing the 'bigger picture' of how things are
best structured.
I have a website made up...
|
by: Michelle Keys |
last post by:
I am trying to call a print function to print a string from a database
using javascript.
Which is RC_DATA of Varchar2(2500).
This is a javascript is not being used. I have a thing that needs to...
|
by: Marcel Gelijk |
last post by:
Hi,
I am trying to create a User Control that is located in a seperate class
library. The User Control contains a textbox and a button.
The page generates an exception when it tries to access...
|
by: Christian Ista |
last post by:
Hello,
To each pages, I have a common part (a graphic part). Is it possible to put
the code (HTML) in a file and insert it in each pages or I have to
copy/paste the code in each pages ?
...
|
by: Vladimír Karásek |
last post by:
Hi there,
does anybody know, how to create a class, which is can be inherited by both
aspx (System.Web.UI.Page) as well as by ascx (System.Web.UI.UserControl)
classes.
I have the bunch of same...
|
by: Chris Kettenbach |
last post by:
Hi I am designing an ASP.net app. Just wanted some opinions on code behind
options. My idea is to have a code behind file that the controls will
reference and have ascx files for the controls. ...
|
by: Ric |
last post by:
im new to asp.net. from what i understand, you have the aspx file
(presentation), user-control(ascx file), code-behind(vb file) and
components(compiled vb and dll files). the aspx file contains a...
|
by: Daniel Manes |
last post by:
Okay, here are the facts ma'am (or mister):
1. I have a user control called "Header" and a main page called
"ReportMatch".
2. I've written "code-behinds" for both the user control and the main...
|
by: SAL |
last post by:
Hello,
I created a WebPage.aspx that has some functions in it, and I created a User
Control that has a File Field Control and a Botton control on the .ascx. I
added myUserControl.ascx to the...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |