R
Ranginald
Hey,
I'm trying to create a simple class to create a textbox, and then
instantiate it from a page (so I can resue it across an asp.net app).
I've been scratching my head but I can't get this to work. I am I in
the right direction?
BaseClass.cs
============
public class BaseClass
{
protected TextBox textBox1;
public BaseClass()
{
}
public void CreateTextBox()
{
TextBox textBox1 = new TextBox();
textBox1.Text = "Hello from BaseClass";
textBox1.EnableViewState = true;
}
Default.aspx
===========
<asplaceHolder ID="PlaceHolder1" runat="server">
Default.aspx.cs
============
BaseClass sample = new BaseClass;
BaseClass.CreateTextBox();
-------> It all compiles but no textbox appears.
1) How do I "tell" the BaseClass.cs to look for the PlaceHolder1 on the
default.aspx page? I always get a not in the current context problem.
2) And how do I "tell" default.aspx.cs that the textBox1 is the
textbox to use?
Any ideas?
Thanks!
-David
I'm trying to create a simple class to create a textbox, and then
instantiate it from a page (so I can resue it across an asp.net app).
I've been scratching my head but I can't get this to work. I am I in
the right direction?
BaseClass.cs
============
public class BaseClass
{
protected TextBox textBox1;
public BaseClass()
{
}
public void CreateTextBox()
{
TextBox textBox1 = new TextBox();
textBox1.Text = "Hello from BaseClass";
textBox1.EnableViewState = true;
}
Default.aspx
===========
<asplaceHolder ID="PlaceHolder1" runat="server">
Default.aspx.cs
============
BaseClass sample = new BaseClass;
BaseClass.CreateTextBox();
-------> It all compiles but no textbox appears.
1) How do I "tell" the BaseClass.cs to look for the PlaceHolder1 on the
default.aspx page? I always get a not in the current context problem.
2) And how do I "tell" default.aspx.cs that the textBox1 is the
textbox to use?
Any ideas?
Thanks!
-David