I am coming from an ASP.Net MVC background, so I like to design things well. I just started getting back into ASP.Net web forms again because my job requires it.
I have a user control which I would like to use to encapsulate an entire component (layout and code). Depending on certain settings for this control the layout may change, or I may call events, etc… Is it good practice to do something like this?
<%# if(this.SomeProperty) …. %> or <%# if(this.something) this.runSomeMethod()) %>
I have no clue what is good design regarding web user controls.
Since this is rather subjective I’ll give you my subjective opinion: Except in very few cases, I prefer to use codebehind to drive control and page logic. I don’t mind “tag soup” per se, but I think it’s far clearer to just do everything in proper code. When you have codebehind you also get the benefit of having a concrete class to refer to, which is useful in many ways, especially in larger projects.
That said, there’s nothing fundamentally wrong with what you’re doing.