Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET: Attribute passed to ascx descends to top-level control but not nested control
    text
    copied!<p>In my ASP.NET project (VB.NET) I have a self-coded user control called DocumentDisplay that I invoke with a TargetWebPage attribute:</p> <pre><code>&lt;uc1:DocumentDisplay ID="DocumentDisplay" runat="server" TargetWebPage="EntityDocumentUpload"/&gt; </code></pre> <p>The codebehind for the user control implements the public property TargetWebPage, and in the debugger I can see it is being set correctly. Also, in the user control (ascx) there is a yyySecureButton defined (line 9), which also has this public property defined in it, and this is being set as well. The problem is I need the property to descend all the way to the yyySecureCommandField defined (within the DomainGridView control) on line 25; this property is in the codebehind for that control as well, but it is not being set.</p> <p>Can I pass the TargetWebPage attribute to the yyySecureCommandField from within the markup? If not, how best to do it?</p> <p>The code below is identical to what I'm working with except that strings identifying my client have been changed to vvv, xxx, yyy, etc.</p> <p>Many thanks for any response.</p> <pre><code>&lt;%@ Control Language="vb" AutoEventWireup="false" CodeBehind="DocumentDisplay.ascx.vb" Inherits="zzz.DocumentDisplay" %&gt; &lt;xxx:ErrorSection ID="ErrorSection" runat="server"/&gt; &lt;div class="FieldGroup"&gt; &lt;fieldset&gt; &lt;legend&gt;Documents&lt;/legend&gt; &lt;xxx:InputField runat="server" ID="InputFieldDocumentType" FieldName="DocumentType" CssClass="DocumentField" SuppressRequiredIndicator="True" /&gt; &lt;xxx:InputField runat="server" ID="InputFieldDocumentName" FieldName="DocumentName" CssClass="DocumentField" SuppressRequiredIndicator="True" /&gt; &lt;div class="DocumentField"&gt;&lt;label&gt;Upload&lt;/label&gt;&lt;input type="File" id="DocumentUpload" runat="server" /&gt;&lt;/div&gt; &lt;div class="TableSectionCommandBar"&gt;&lt;vvv:yyySecureButton id="ButtonUpload" runat="server" SecurityMode="Action" Text="Add" CssClass="StandardButton"/&gt;&lt;/div&gt; &lt;div class="Spacer" /&gt; &lt;div class="TableSection"&gt; &lt;xxx:DomainGridView ID="GridViewDocuments" runat="server" AutoGenerateColumns="False" CssClass="StandardTable" DomainObjectName="zzz.Domain.Document,yyyLib" DataKeyNames="DocumentId" AlwaysRequiresDatabind="True" AllowSorting="True"&gt; &lt;Columns&gt; &lt;xxx:FieldDefinitionField FieldName="DocumentType" ShowToolTip="True" SortExpression="DocumentType" /&gt; &lt;xxx:FieldDefinitionField FieldName="DocumentName" ShowToolTip="True" SortExpression="DocumentName" /&gt; &lt;xxx:FieldDefinitionField FieldName="DocumentDate" IsReadOnly="True" ShowToolTip="True" SortExpression="DocumentDate" /&gt; &lt;asp:TemplateField HeaderText="Doc" ItemStyle-HorizontalAlign="Center"&gt; &lt;ItemTemplate&gt; &lt;asp:Hyperlink ID="LinkViewContentDocuments" runat="server" Visible="&lt;%#Not String.IsNullOrEmpty(DirectCast(Container.DataItem, DocumentInformation).DocumentFileName)%&gt;" NavigateUrl="&lt;%#ResolveUrl(String.Format(CultureInfo.InvariantCulture, ApplicationUrls.ViewEntityDocuments, DirectCast(Container.DataItem, DocumentInformation).DocumentId))%&gt;" ImageUrl="&lt;%#ResolveUrl(ApplicationUrls.PaperclipImage)%&gt;" ToolTip="&lt;%#DirectCast(Container.DataItem, DocumentInformation).DocumentFileName%&gt;" Text="&lt;%#DirectCast(Container.DataItem, DocumentInformation).DocumentFileName%&gt;" /&gt; &lt;/ItemTemplate&gt; &lt;EditItemTemplate&gt; &lt;input type="File" id="UpdateDocumentUpload" runat="server" /&gt; &lt;/EditItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;vvv:yyySecureCommandField SecurityMode="Action" EditText="Edit" UpdateText="Update" CancelText="Cancel" DeleteText="Delete" ShowCancelButton="True" ShowEditButton="True" ShowDeleteButton="True" /&gt; &lt;/Columns&gt; &lt;EmptyDataTemplate&gt; &lt;asp:Label ID="LabelNoEntityResults" runat="server" Text="There are currently no documents to display."&gt;&lt;/asp:Label&gt; &lt;/EmptyDataTemplate&gt; &lt;RowStyle CssClass="ItemRow" /&gt; &lt;HeaderStyle CssClass="HeaderRow" /&gt; &lt;AlternatingRowStyle CssClass="AlternatingItemRow" /&gt; &lt;PagerStyle CssClass="PagingRow" /&gt; &lt;/xxx:DomainGridView&gt; &lt;/div&gt; &lt;/fieldset&gt; &lt;/div&gt; </code></pre>
 

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