I have abstract UserControlBase class inheriting from System.Web.UI.UserControl.
It only class, without markup, because I it’s abstract base class.
Can I somehow define controls such as TextBoxes, DropDownLists etc. in this abstract base class, use them in methods, but markup define in children’s usercontrol inherited from UserControlBase?
Pseudocode:
abstract UserControlBase : System.Web.UI.UserControl
{
private TextBox txt1;
private DropDownList ddl1;
private void test()
{
txt1.Text = "test";
ddl1.SelectedIndex = 0;
}
}
MyUserControl : UserControlBase
(markup):
<asp:TextBox ID="txt1" runat="server" />
<asp:DropDownList ID="ddl1" runat="server" />
Thank you.
Just make the controls in base class protected, not private:
Also I suggest your UserControlBase is simple class (single *.cs file, no markup).