Search code examples
c#user-controlsascx

Can two ascx files share the same code file?


I have two files:

SomeUserControl.en.ascx
SomeUserControl.fr.ascx

I'd like them to share the same code file:

SomeUserControl.ascx.cs

This is on a NON-compiled site and the files are IDENTICAL except for the language. In THIS case, using Localization is NOT an option.

Will this work:

CodeFile="SomeUserControl.ascx.cs"

These are not compiled files... but rather xcopy deployment.


Solution

  • Sure, we have a project like that. Look for this attribute on your aspx/ascx page:

    <%@  ... CodeBehind="YourClassFile.ascx.cs" ... %>