Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing Web User Controls instead of Web Forms
    text
    copied!<p>I've been using ASP.NET (C#) for the past two years. I have learned so much but there is still much more to learn :)</p> <p>I've used MasterPages, 'Web User Controls' for things like headers, navigation, footers etc.</p> <p>One thing I have never truly understood is the practice of using 'Web User Controls' for your content and logic;</p> <pre><code>Home.aspx ------ Home.ascx AboutUs.aspx ----- AboutUs.ascx Ordering.aspx ---- Ordering.acsx </code></pre> <p>I've been working with a few projects over the last few months that use this structure. I am aware that this is actually common practice but I don't really understand the full benefits.</p> <p>I remember when I tried this approach before and ended up having awful viewstate problems with controls like the Gridview... once I took all the logic out and placed it into a .aspx page everything worked fine.</p> <p>I realise now that maybe I needed to add the Gridview to the viewstate collection... but this only reinforces my difficulty into understanding why this approach is used - given the viewstate problem.</p> <p>I fully understand the advantages of 'Web User Controls' in relation to things like Headers, menus, footers etc... anywhere that involves duplication but the projects I've seen have pages/controls that are pretty specific - in other words its unlikely to be reused anywhere else - the aspx page just contains a control (.ascx) with the content and logic and it will only be used on that page, nowhere else.</p> <p><strong>Ignoring 'Code Reuse', what other benefits does this approach provide?</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload