I have trying to have a webform inherit controls from another form and can't
get it to work
Say I have a form that saves the person's demographic info.
****one.aspx****
//I have an object to save the person's name in code behind
protected void SavePersonInfo(Person p)
{
p.First = txtFirstName.Text;
p.Last = txtLastName.Text;
p.Save();
}
******************
Then I have another customer that wants the same form, but would like the
person's gender and age in additioon to the first and last names.
Ideally, I should be able to have a form that inherits the form above and do
****derived.aspx**************
protected new void SavePersonInfo(Person p)
{
p.Age = txtAge.Text;
p.Gender = cmbGender.SelectedValue;
base.SavePersonInfo();
}
********************
I just don't want to have to repeat the code behind for first and last names
for the second customer's form. So ideally the derived form inherits
txtFirstName and txtLastName.
But the problem is VS.NET won't let you. When I draw txtFirstName, and
txtLastName, VS.NET keeps declaring them as class level controls in the
derived class. I comment them out and they keep coming back. After I comment
them out, I can compile and run and the code expects the way I want it to,
but the bam, these two lines keep come back again.
protected TextBox txtFirstName;
protected TextBox txtLastName;