Thursday, 22 August 2013

Can ASPX pages share code behind file?

Can ASPX pages share code behind file?

Let say i have two ASPX pages with identical server-side controls.
~/TemplateA/Contact.aspx
~/TemplateB/Contact.aspx
By default, they are mapped to their respective code-behind file.
~/TemplateA/Contact.aspx.cs
~/TemplateB/Contact.aspx.cs
Instead, I would like them to point to a single, common code-behind file, as
~/Classes/Contact.aspx.cs
I already have them inheriting from a base "Contact" function class, who
exposes the whole business-logic, but I still can't figure how to refer
the server-side controls of the pages into the base "Contact" class; as
example, I would like to be able to write:
this.textBox1.Text = "Hello"
in my base class instead of writing it in each single .cs file. Obviously,
"textBox1" isn't a known object in my base class as it has no designer
file attached.
Is it possible? Anyone can help?

No comments:

Post a Comment