Reputation: 25938
In my home page I have 3 sections; Services, About and Portfolio.
I want to separate the HTML/code for each of these sections into their own files (WebForms/UserControls) so I can reuse these on other pages.
In ASP.NET WebForms; is the correct way to construct these sections as UserControls or WebForms with no master file?
As I understand a UserControl is more for a custom widget/tag such as a custom GridView or something. So maybe UserControls wouldn't suit this?
Eg;
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="My._Default" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
// Include About
// Include Services
// Include Portfolio
</asp:Content>
Upvotes: 1
Views: 87
Reputation: 7696
In case you are going to reuse the sections across the web site I'd go with UserControls. It's more versatile. If you'd put the code to web forms you'd be dependent on the masterpage's ContentPlaceHolder
.
Upvotes: 1