在Aspx页面上动态设置UserControl属性

时间:2017-12-27 17:21:38

标签: asp.net webforms

我正在制作一个通用的模态用户控件,我可以在不同的Aspx页面上调用并通过参数设置文本。首先,我在UserControl的Codebehind上创建了2个属性

    public partial class _modalGenerica : System.Web.UI.UserControl
    {
        public string Body { get; set; }
        public string Title { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}

我在ascx上创建了模态按钮并尝试访问属性

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="_modalGenerica.ascx.cs" Inherits="GS1.CNP.WEBUI.views.backoffice.areaEstatica.formularioProduto._modalGenerica" %>






<button type="button" class="btn btn-lg btn-danger" data-toggle="popover" title="<%this.Title%>" data-content="<%this.Body%>"> Click to toggle popover</button>

最后我用这行

在aspx页面上调用UC
<partial:_modalGenerica runat="server" id="_modalGenerica" Body="Hhahaha" Title="Teste" />

我创建按钮模式后,aspx页面没有加载,任何想法?或更好的解决方案?

0 个答案:

没有答案