473,326 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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 1790
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**********@NO.SPAMiprimus.com.au> wrote in message
news:%2***************@TK2MSFTNGP10.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
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...
1
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...
3
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...
20
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...
2
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...
0
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...
4
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...
5
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...
0
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.