Reputation: 11498
Is it possible to separate the ascx ("view") and the ascx.cs ("controller") pars of a user control. Id like to move the controller part to App_Code to be resued while the view part is changed between projects?
Upvotes: 1
Views: 74
Reputation: 1062540
In regular ASP.NET, even if you separate the code-behind and the ascx - they are still tightly coupled. It isn't a true "controller" (as separate from a view).
If you want this purity, consider ASP.NET MVC, which (obviously) addresses this in a different way.
Upvotes: 2
Reputation: 4173
Yes, write the codebehind in some service class which extends UserControl, and in your .ascx file inherit that class
<%@ Control
Language = "C#"
Inherits = "Project.Business.Service.MyControl"
%>
Upvotes: 2