Note that there are some explanatory texts on larger screens.

plurals
  1. POSet Custom ASP.NET UserControl variables when its in a Repeater
    primarykey
    data
    text
    <pre><code>&lt;%@ Register Src="~/Controls/PressFileDownload.ascx" TagName="pfd" TagPrefix="uc1" %&gt; &lt;asp:Repeater id="Repeater1" runat="Server" OnItemDataBound="RPTLayer_OnItemDataBound"&gt; &lt;ItemTemplate&gt; &lt;asp:Label ID="LBLHeader" Runat="server" Visible="false"&gt;&lt;/asp:Label&gt; &lt;asp:Image ID="IMGThumb" Runat="server" Visible="false"&gt;&lt;/asp:Image&gt; &lt;asp:Label ID="LBLBody" Runat="server" class="layerBody"&gt;&lt;/asp:Label&gt; &lt;uc1:pfd ID="pfd1" runat="server" ShowContainerName="false" ParentContentTypeId="55" /&gt; &lt;asp:Literal ID="litLayerLinks" runat="server"&gt;&lt;/asp:Literal&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; System.Web.UI.WebControls.Label lbl; System.Web.UI.WebControls.Literal lit; System.Web.UI.WebControls.Image img; System.Web.UI.WebControls.HyperLink hl; System.Web.UI.UserControl uc; </code></pre> <p>I need to set the ParentItemID variable for the uc1:pdf listed inside the repeater. I thought I should be able to find uc by looking in the e.Item and then setting it somehow. I think this is the part where I'm missing something.</p> <pre><code>uc = (UserControl)e.Item.FindControl("pfd1"); if (uc != null) { uc.Attributes["ParentItemID"] = i.ItemID.ToString(); } </code></pre> <p>Any thoughts would be appreciated.</p> <p>Also tried this with similar results... when I debug inside my usercontrol (pfd1) the parameters I am trying to set have not been set.</p> <pre><code>uc = (UserControl)e.Item.FindControl("pfd1"); if (uc != null) { uc.Attributes.Add("ContainerID", _cid.ToString()); uc.Attributes.Add("ParentItemId", i.ItemID.ToString()); } </code></pre> <p>UPDATE: It looks like my controls are not connected by a namespace. I've wrapped by the parent control (Layer) and the PressFileDownlad control in a namespace "MyControls". Also updated their Inherits reference on the aspx to read "MyControls.xxxxx". I'm able to type "MyControls.Layer" inside the code on layer.aspx.cs but I'm not able to get "MyControls.PressFileDownload"</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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