473,569 Members | 2,782 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inheriting Webforms in C#

Hi,

Just to get started....

I've created a very simple web form, "Simple", using VS and I dropped a
HTML img control on the design view. I referenced a picture and it is
displayed in browser view. Very simple.

I have created a second form and in the code-behind page I have altered the
class definition to inherit from, "Simple".

When viewing the second form in the browser the 'inherited' image from the
first form is not shown.

Examples I have found of web form inheritance tend to all deal with the
"Simple" form being only a code page (a class) that renders its content in
code rather than having any design view.

Can a Webform only inherit content from a base class that is code only or
can content in the .aspx file also be inherited?

Thanks,

gramps
Nov 19 '05 #1
2 1825
Big question. The HTML cant be inherited but there are workarounds such as
reading the HTML frmo a File and merging you content into it or it into your
content,.
Nov 19 '05 #2
Hi Simon,

Let me see if I can explain a bit about WebForms, the CodeBehind model, and
Inheritance. Forgive me if I mention anything you already know; I just want
to cover all the bases. I will begin with Inheritance. Put simply, a class
that inherits another class obtains all of the characteristics of the
inherited class, Properties, Fields, Methods, etc. The new class can now
extend the inherited class by adding other characteristics to it. This, of
course, has no effect on the inherited class.

The CodeBehind model is a way of separating Interface (HTML and related
server-side tags) and Interface business logic. What you refer to as "design
view" is actually a Template. It inherits the CodeBehind class. If you take
a look at the HTML view of that file, you will see the Inherits statement in
the @Page tag. So, you can only inherit from the CodeBehind class.

IOW, if you want to inherit a Control from a Page class, it will have to be
declared in the CodeBehind class that you inherit from, and there will have
to be a tag in the inheriting template, or the Control will have to be
dynamically created in the CodeBehind.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"Simon" <si**********@N O.SPAMiprimus.c om.au> wrote in message
news:%2******** *******@TK2MSFT NGP10.phx.gbl.. .
Hi,

Just to get started....

I've created a very simple web form, "Simple", using VS and I dropped a
HTML img control on the design view. I referenced a picture and it is
displayed in browser view. Very simple.

I have created a second form and in the code-behind page I have altered
the class definition to inherit from, "Simple".

When viewing the second form in the browser the 'inherited' image from the
first form is not shown.

Examples I have found of web form inheritance tend to all deal with the
"Simple" form being only a code page (a class) that renders its content in
code rather than having any design view.

Can a Webform only inherit content from a base class that is code only or
can content in the .aspx file also be inherited?

Thanks,

gramps

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3583
by: rachel | last post by:
Hi all, I am new in ASP.Net. I have a question on link multiple web forms together. Here is the scenario: I create an Index.aspx WebForm which consists of a banner and three navigator buttons as well as a body to load the content. It is exactly like a normal HTML page where there are banner, menu bar, and body to load content. In my case,...
1
1713
by: Paul R | last post by:
Hi, I have a Winforms application that access some SQLServer2000 stored procedures. I have now written some new Webforms pages to use some of the same stored procs. The Webforms use the SAME data access classes (all of my business logic and data access classes are in DLLs that are shared between the Winforms and Webforms).
3
1264
by: Netserver | last post by:
Hi have a question hope there is a simple answer. I want to enter data in to 2 arrays from several webforms in project and be able to recall that data from any of the webforms, other then using a querystring I tried creating a module as follows Module dataspecs Public ar1(0) As Integer Public ar2(0) As Integer End Module
20
2880
by: Martin Rosén-Lidholm | last post by:
Although an impossible question to answer, I fell urged to raise it anyhow. Given a fairly complex ERP application scenario, what's your estimation for the X-ratio dev. time for WebForms app
2
1493
by: Piotr Karwatka | last post by:
Hi! I have a little problem an qeustion. In .NET Windows Forms I can do something like that: - i have forms - Form1 Form2, on first form i have TextBox1 control on 2nd form I have Button1 control - on second Form i can acces data from Form1 like that: for example: MessageBox.Show(Form1.TextBox1.Text);
0
954
by: Billy Cormic | last post by:
Hi, I am new to asp.net but have done quite a bit of applications programming. I would like to create a base class webform that other webforms can inherit from. Let's say Webform1 is the base class and webform2 is the form that would like to inherit all of the subroutines and controls from webform1. I have tried the following which does...
4
3926
by: 3Cooks | last post by:
I have a windows application written in Visual Basic 6.0 that is going to be redeveloped in dotNET. We are trying to decide if we should deploy using Webforms or Winforms and I need advice from someone who is not on my team. The VB 6.0 application is used by approximately 100 users. All users reside in-house. There is an existing...
5
4933
by: Bit byte | last post by:
Can I use C# (Winforms) to design a website?. I am from C/C++ background but know nothing about Internet programming. My understanding of WebForms are that they are similar to WinForms in that they give a WYSIWYG environment for designing user interfaces - however, all searches I have done on WebForms display the actual HTML, not a WYSIWYG...
0
1923
by: JM | last post by:
Hi, I have uploaded an application written in asp.net 2.0 on server. By web controls started giving Javascript error and I figured it out from discussion groups that I have to put WebForms.js file with the aspx pages. But I am unable to find out WebForms.js file in .NET 2.0 . I have searched my PC also (I have VS 2005 and .NET 2.0) but...
0
7693
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7917
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7665
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6277
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.