First off all, sorry about my english.
I Have been searching in several forums about this question, and here i found a similar question about this problem. But have some time now i cant find a solution, so i will ask the answer by explaining my context.
The thing is, i have a "Web User Control" and some code, that i used from here actualy, for create a ContentTemplate that i can put some html or other controls inside. And it works almost well, the thing is that when i trying to see by the designer, the designer shows me "System.Web.UI.UserControl" Does not have a property named 'ContentTemplate'. I'm trying several's solutions like this tag [PersistenceMode(PersistenceMode.InnerProperty)] and some others that i cant remember of my head.
Here is the Control code: ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="FormGroup.ascx.cs" Inherits="Repl4y.Controllers.FormGroup" %>
<div class="form-group">
<asp:PlaceHolder runat="server" ID="BodyControlSpace"></asp:PlaceHolder>
</div>
C#
public partial class FormGroup : System.Web.UI.UserControl
{
private ITemplate _ContentTemplate;
[PersistenceMode(PersistenceMode.InnerProperty)]
public ITemplate ContentTemplate
{
get { return _ContentTemplate; }
set { _ContentTemplate = value; }
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
_ContentTemplate.InstantiateIn(BodyControlSpace);
}
protected void Page_Load(object sender, EventArgs e)
{
}
}
The Test Page Cadppg.aspx:
<%@ Page Title="" Language="C#" MasterPageFile="~/AreaRestrita.Master" AutoEventWireup="true" CodeBehind="Cadppg.aspx.cs" Inherits="Repl4y.Cadppg" %>
<%@ Register Assembly="Repl4y" Namespace="Repl4y.Controllers" TagPrefix="My" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<My:FormGroup runat="server" >
<ContentTemplate>
<My:Painel runat="server" ID="Painel1" _Label="teste" _Number="22" />
<My:Painel runat="server" ID="Painel2" _Label="teste" _Number="22" />
</ContentTemplate>
</My:FormGroup>
I cant put image yet because i dont have enough reputation, but soon i'll post the error.
Theres some way to trick the visual studio and create other ContentTemplate property with other type, like string, or something to make the 'design' works, i really will need because my controls is just integration with bootstrap and i'll use the designer to create event handlers like onclicks in buttons, etc.
Thanks.!
Aucun commentaire:
Enregistrer un commentaire