My current situation:
I have a user control A.ascx with code behind A.ascx.cs and B.ascx with code behind B.ascx.cs.
Both code behind files contain similar code. Now I want to create only one CS file e.g. C.cs
which can be used by A.ascx and B.ascx.
Of course, C.cs must be able to access controls by ID which were used inside A.ascx and B.ascx.
Is this possible?
No, but you can create single class and use it from both code behing classes. You can pass user control to that class and access controls by ID.
Any if you wont typed access to controls do something like this :
common class and interface that defines child controls that are on both user controls, and here you can access child controls :
and then on all User controls you must implement the ICommonUserControl interface, something like this :
And at the end here is the example of usage :