473,399 Members | 3,888 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,399 software developers and data experts.

Inheriting Web Forms

All,

What is the best way to inherit from an existing webform? I have a simple
ASP page which displays the results of a DB query in a datagrid.

I now want to use the existing code, to display the results of a different
query, but with the same peripheral code (formatting of the datagrid for
instance).

I've managed to get this working as so:

1) Create a new webform and inherit this in the c# from the base form
instead of Page.
2) Cut and paste the HTML generated for the base form, changing the
codebehind and inherits to point to the subclass form.

Now this works, until VS.NET decides to (by looking at the HTML, I presume),
add a new datagrid variable to the subclass. If I delete this declaration
then everything wroks as I intend. However flicking back and forth between
design and code views always regenerates these decs.

Am I doing something wrong? If not, is there a workaround?

Shak
Nov 19 '05 #1
2 1041
Instead of using the <B>codebehind</B> attribute in the PAGE directive try to
use <B>src</B> attribute and give the name of path of the associated .cs file
for it.

Hope this helps

"Shak" wrote:
All,

What is the best way to inherit from an existing webform? I have a simple
ASP page which displays the results of a DB query in a datagrid.

I now want to use the existing code, to display the results of a different
query, but with the same peripheral code (formatting of the datagrid for
instance).

I've managed to get this working as so:

1) Create a new webform and inherit this in the c# from the base form
instead of Page.
2) Cut and paste the HTML generated for the base form, changing the
codebehind and inherits to point to the subclass form.

Now this works, until VS.NET decides to (by looking at the HTML, I presume),
add a new datagrid variable to the subclass. If I delete this declaration
then everything wroks as I intend. However flicking back and forth between
design and code views always regenerates these decs.

Am I doing something wrong? If not, is there a workaround?

Shak

Nov 19 '05 #2
Try to use the SRC attribute in the PAGE directive of the ASPX page in place
of the existing CODEBEHIND attribute and give the path of the associated .cs
file as the value of the SRC attribute.

Hope this helps.

"Shak" wrote:
All,

What is the best way to inherit from an existing webform? I have a simple
ASP page which displays the results of a DB query in a datagrid.

I now want to use the existing code, to display the results of a different
query, but with the same peripheral code (formatting of the datagrid for
instance).

I've managed to get this working as so:

1) Create a new webform and inherit this in the c# from the base form
instead of Page.
2) Cut and paste the HTML generated for the base form, changing the
codebehind and inherits to point to the subclass form.

Now this works, until VS.NET decides to (by looking at the HTML, I presume),
add a new datagrid variable to the subclass. If I delete this declaration
then everything wroks as I intend. However flicking back and forth between
design and code views always regenerates these decs.

Am I doing something wrong? If not, is there a workaround?

Shak

Nov 19 '05 #3

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

Similar topics

1
by: Yasutaka Ito | last post by:
Hi, I have a base form (FormBase), which defines things like the value of the WindowState. Other forms inherit from this base form to reflect the layout given in the base form. Is there a way...
3
by: thechaosengine | last post by:
Hi all, I wanted to put some common security functions into a class that inherits from the Page class and then use the new class as the basis for all my pages. Unfortunately, if I try and...
1
by: Rasmus Kromann-Larsen | last post by:
Hey, I'm working on an application (questionaire) with alot of different question types (very different form layout)... But the questions share attributes, however - since I'm working in the...
2
by: Charles Law | last post by:
I want a set of controls that all have a border, like a group box. I thought I would create a base control containing just a group box from which my set of controls could inherit. Assuming that...
5
by: Ed Willis | last post by:
What is the best way to make a window read only for an inherited window. How do I access the all the controls such as textboxes etc. to make everything read only? I have an update window that I am...
4
by: Xero | last post by:
Hello. I am using vb.net. There are two forms in my project. One is 'base' and the other one is 'savecurrent'. There is a value stored in a textbox called 'qc_a' in 'base'. I want to inherit...
3
by: Geraldine Hobley | last post by:
Hello, In my project I am inheriting several forms. However when I inherit from a form and add additional subroutines and methods to my inherited form I get all sorts of problems. e.g. I sometimes...
7
by: Vish | last post by:
Hi, I have a base form from which i want all of my forms to inherit from. The base form has three buttons anchored to the bottom right of the base form. When i first inherit a new form from the...
5
by: UJ | last post by:
I have a user control that inherits from the standard windows text box. I have a routine that adds stuff to it. I have compiled it into a dll. I have added it to my app and I can debug into it. I...
1
by: BillE | last post by:
Can I inherit from a web form? I would like to reuse procedures in a web form base class code behind by inheriting from it. For example, I would like to have a HandleError function defined in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
0
BarryA
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...
1
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...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...

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.