ASP.NET:传递给ascx的属性下降到顶级控件但不是嵌套控件

时间:2013-01-08 18:35:19

标签: asp.net controls ascx

在我的ASP.NET项目(VB.NET)中,我有一个名为DocumentDisplay的自编码用户控件,我使用TargetWebPage属性调用它:

<uc1:DocumentDisplay ID="DocumentDisplay" runat="server" TargetWebPage="EntityDocumentUpload"/>

用户控件的代码隐藏实现了公共属性TargetWebPage,在调试器中我可以看到它正确设置。此外,在用户控件(ascx)中定义了yyySecureButton(第9行),其中也定义了此公共属性,并且也正在设置此属性。问题是我需要将属性一直下降到第25行定义的yyySecureCommandField(在DomainGridView控件内);

这个属性也在该控件的代码隐藏中,但它没有被设置。

我可以从标记内将TargetWebPage属性传递给yyySecureCommandField吗?如果没有,最好怎么做?

以下代码与我正在使用的代码相同,只是识别我的客户端的字符串已更改为vvv,xxx,yyy等。

非常感谢您的回应。

<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="DocumentDisplay.ascx.vb" Inherits="zzz.DocumentDisplay" %>
<xxx:ErrorSection ID="ErrorSection" runat="server"/>
<div class="FieldGroup">
    <fieldset>
        <legend>Documents</legend>
        <xxx:InputField runat="server" ID="InputFieldDocumentType" FieldName="DocumentType" CssClass="DocumentField" SuppressRequiredIndicator="True" />
        <xxx:InputField runat="server" ID="InputFieldDocumentName" FieldName="DocumentName" CssClass="DocumentField" SuppressRequiredIndicator="True" />
        <div class="DocumentField"><label>Upload</label><input type="File" id="DocumentUpload" runat="server" /></div>
        <div class="TableSectionCommandBar"><vvv:yyySecureButton id="ButtonUpload" runat="server" SecurityMode="Action" Text="Add" CssClass="StandardButton"/></div>
        <div class="Spacer" />
        <div class="TableSection">
            <xxx:DomainGridView ID="GridViewDocuments" runat="server" AutoGenerateColumns="False" CssClass="StandardTable" DomainObjectName="zzz.Domain.Document,yyyLib" DataKeyNames="DocumentId" AlwaysRequiresDatabind="True" AllowSorting="True">
                <Columns>
                    <xxx:FieldDefinitionField FieldName="DocumentType" ShowToolTip="True" SortExpression="DocumentType" />
                    <xxx:FieldDefinitionField FieldName="DocumentName" ShowToolTip="True" SortExpression="DocumentName" />
                    <xxx:FieldDefinitionField FieldName="DocumentDate" IsReadOnly="True" ShowToolTip="True" SortExpression="DocumentDate" />
                    <asp:TemplateField HeaderText="Doc" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:Hyperlink ID="LinkViewContentDocuments" runat="server" Visible="<%#Not String.IsNullOrEmpty(DirectCast(Container.DataItem, DocumentInformation).DocumentFileName)%>" NavigateUrl="<%#ResolveUrl(String.Format(CultureInfo.InvariantCulture, ApplicationUrls.ViewEntityDocuments, DirectCast(Container.DataItem, DocumentInformation).DocumentId))%>" ImageUrl="<%#ResolveUrl(ApplicationUrls.PaperclipImage)%>" ToolTip="<%#DirectCast(Container.DataItem, DocumentInformation).DocumentFileName%>" Text="<%#DirectCast(Container.DataItem, DocumentInformation).DocumentFileName%>" />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <input type="File" id="UpdateDocumentUpload" runat="server" />
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <vvv:yyySecureCommandField SecurityMode="Action" EditText="Edit" UpdateText="Update" CancelText="Cancel" DeleteText="Delete" ShowCancelButton="True" ShowEditButton="True" ShowDeleteButton="True" />
                </Columns>
                <EmptyDataTemplate>
                    <asp:Label ID="LabelNoEntityResults" runat="server" Text="There are currently no documents to display."></asp:Label>
                </EmptyDataTemplate>
                <RowStyle CssClass="ItemRow" />
                <HeaderStyle CssClass="HeaderRow" />
                <AlternatingRowStyle CssClass="AlternatingItemRow" />
                <PagerStyle CssClass="PagingRow" />
            </xxx:DomainGridView>
        </div>
    </fieldset>
</div>

0 个答案:

没有答案