Inheriting Web Forms

S

Shak

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
 
G

Guest

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.
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top