Question About Inherited WebForm Classes Containing Components

M

Mark Olbert

I'm confused about the behavior of inherited WebForms under VS/NET 2003.

In the Windows.Forms world, if I create a UserControl with a protected component on it, that
protected component is visible (albeit locked) and accessible in any class derived from the custom
control.

But in ASP.NET, if I create a WebForm1 class and add, say, a DataSet component to it, it's not
visible in any derived classes, even though it, too, is protected.

The reason I'm curious about this is that I have a bunch of common database functionality that I
would like to encapsulate in a base WebForm class. Right now I don't see how that can be done,
because things like the base DataSet object would not be visible in the derived classes.

Is it possible that this just can't be done in VS/NET 2003?

- Mark
 
W

William F. Robertson, Jr.

Are you saying this code doesn't work on your machine?

public class WebForm1 : System.Web.UI.Page
{
protected DataSet myData = new DataSet();
....
}

public WebForm2 : WebForm1
{
...
private void Method()
{
//this will work.
this.myData.Tables[0]......
}
}

bill
 
M

Mark Olbert

Not quite. What I meant is that if you drag and drop a DataSet component onto WebForm1 using the
visual designer, it doesn't show up in WebForm2.

Also, if you drag and drop a DataSet component (or an SqlDataAdapter, etc.) onto WebForm2 (derived
from WebForm1) and recompile, the DataSet disappears from the WebForm2 visual designer.

- Mark

Are you saying this code doesn't work on your machine?

public class WebForm1 : System.Web.UI.Page
{
protected DataSet myData = new DataSet();
....
}

public WebForm2 : WebForm1
{
...
private void Method()
{
//this will work.
this.myData.Tables[0]......
}
}

bill

I'm confused about the behavior of inherited WebForms under VS/NET 2003.

In the Windows.Forms world, if I create a UserControl with a protected component on it, that
protected component is visible (albeit locked) and accessible in any class derived from the custom
control.

But in ASP.NET, if I create a WebForm1 class and add, say, a DataSet component to it, it's not
visible in any derived classes, even though it, too, is protected.

The reason I'm curious about this is that I have a bunch of common database functionality that I
would like to encapsulate in a base WebForm class. Right now I don't see how that can be done,
because things like the base DataSet object would not be visible in the derived classes.

Is it possible that this just can't be done in VS/NET 2003?

- Mark
 

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

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top