Cargar un user control en el ContentPlaceHolder del master page
-
viernes, 21 de septiembre de 2012 15:34
Hola tengo un master page con tres regiones (div) desde la región de menú de navegación, quiero cargar en un placeholder un usercontrol01, usercontrol02, .....; ademas cada vez cargo una pagina mi encabezado se desconfigura no hereda la plantilla master, como puedo hacerlo correctamente gracias.
mi Site1.master
<%@ Master Language="VB" AutoEventWireup="false" CodeBehind="Site1.master.vb" Inherits="EjemploMasterPage.Site1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>PLANTILLA</title> <link href="StyleSheet.css" rel="stylesheet" type="text/css" /> </head> <body background="images/fondoWebForm.jpg"> <div id="contenedor"> <form id="form1" runat="server"> <div id="header"> <span> <img src="images/sath.jpg" /> PLANTILLA</span> </div> <div id="navigation"> <ul> <li> <asp:HyperLink runat="server" ID="lnkHome" NavigateUrl="~/Default.aspx">Home</asp:HyperLink></li> <asp:Repeater runat="server" ID="menu" DataSourceID="SiteMapDataSource1" EnableViewState="false"> <ItemTemplate> <li> <asp:HyperLink runat="server" NavigateUrl='<%# Eval("Url") %>'> <%# Eval("Title") %> </asp:HyperLink> <asp:Repeater runat="server"> <HeaderTemplate> <ul> </HeaderTemplate> <ItemTemplate> <li> <asp:HyperLink runat="server" NavigateUrl='<%# Eval("Url") %>'> <%#Eval("Title")%> </asp:HyperLink> </li> </ItemTemplate> <FooterTemplate> </ul> </FooterTemplate> </asp:Repeater> </li> </ItemTemplate> </asp:Repeater> </ul> <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="false" /> </div> <div id="content"> <asp:ContentPlaceHolder ID="MainContent" runat="server"> <!-- Page-specific content will go here... --> </asp:ContentPlaceHolder> </div> <div id="pie"> </div> </form> </div> </body> </html>Default.aspx
<%@ Page Language="VB" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeFile="~/Default.aspx.vb" Inherits="_Default" Title="Prueba"%> <%@ MasterType VirtualPath="~/Site1.Master" %> <asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server"> <h1>Contenido de una pagina aspx</h1> </asp:Content>Web.sitemap
<?xml version="1.0" encoding="utf-8" ?> <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" > <siteMapNode url="~/Default.aspx" title="Home" description="Home"> <siteMapNode title="Basic Reporting" url="~/BasicReporting/Default.aspx" description="Basic Reporting Samples"> <siteMapNode url="~/BasicReporting/SimpleDisplay.aspx" title="Simple Display" description="Displays the complete contents of a database table." /> <siteMapNode url="~/BasicReporting/DeclarativeParams.aspx" title="Declarative Parameters" description="Displays a subset of the contents of a database table using parameters." /> <siteMapNode url="~/BasicReporting/ProgrammaticParams.aspx" title="Setting Parameter Values" description="Shows how to set parameter values programmatically." /> </siteMapNode> <siteMapNode title="Filtering Reports" url="~/Filtering/Default.aspx" description="Samples of Reports that Support Filtering"> <siteMapNode url="~/Filtering/FilterByDropDownList.aspx" title="Filter by Drop-Down List" description="Filter results using a drop-down list." /> <siteMapNode url="~/Filtering/MasterDetailsDetails.aspx" title="Master-Details-Details" description="Filter results two levels down." /> <siteMapNode url="~/Filtering/DetailsBySelecting.aspx" title="Details of Selected Row" description="Show detail results for a selected item in a GridView." /> </siteMapNode> <siteMapNode title="Customized Formatting" url="~/CustomFormatting/Default.aspx" description="Samples of Reports Whose Formats are Customized"> <siteMapNode url="~/CustomFormatting/CustomColors.aspx" title="Format Colors" description="Format the grid's colors based on the underlying data." /> <siteMapNode url="~/CustomFormatting/GridViewTemplateField.aspx" title="Custom Content in a GridView" description="Shows using the TemplateField to customize the contents of a field in a GridView." /> <siteMapNode url="~/CustomFormatting/DetailsViewTemplateField.aspx" title="Custom Content in a DetailsView" description="Shows using the TemplateField to customize the contents of a field in a DetailsView." /> <siteMapNode url="~/CustomFormatting/FormView.aspx" title="Custom Content in a FormView" description="Illustrates using a FormView for a highly customized view." /> <siteMapNode url="~/CustomFormatting/SummaryDataInFooter.aspx" title="Summary Data in Footer" description="Display summary data in the grid's footer." /> </siteMapNode> </siteMapNode> </siteMap>
Gracias por sus respuestas.
Todas las respuestas
-
viernes, 21 de septiembre de 2012 16:00Moderador
o sea lo que quieres cambiar el template del repeater ?
el tema es que no se como es que vas a implementar el uso de dos user control, que logica se usaria para definir usar uno u otro
saludos
Leandro Tuttini
Blog
Buenos Aires
Argentina -
viernes, 21 de septiembre de 2012 22:21
Después de intentar logre conseguirlo, gracias por la observación Leandro.
Default.aspx
<%@ Page Language="VB" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeFile="~/Default.aspx.vb" Inherits="_Default" Title="Prueba" %> <%@ Reference Control="~/WebUserControl1.ascx" %> <%@ Register Src="WebUserControl1.ascx" TagName="WebUserControl1" TagPrefix="uc1" %> <asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server"> <uc1:WebUserControl1 ID="WebUserControl11" runat="server" /> </asp:Content>Espero también les sirva.
- Marcado como respuesta Eder CostaModerator martes, 25 de septiembre de 2012 14:07

