簡體   English   中英

從文件背后的代碼中使用C#獲取自定義屬性的值

[英]Get value of custom attribute with c# from the code behind file

我在下面的代碼中為div動態分配了“數據順序”屬性的值。 我希望能夠使用c#從文件背后的代碼中獲取此值,但是很遺憾,我無法弄清楚該怎么做。

<asp:ListView ID="display_backlog" runat="server" DataSourceID="get_backlog" DataKeyNames="story_id">
    <EmptyDataTemplate>
        <p>There is no stories in the product backlog for this project.</p>
    </EmptyDataTemplate>
    <ItemTemplate>
        <div class="row" CssClass="sortable-item" runat="server" data-order="" data-id='<%# Eval("story_id") %>'>
                <div class="col-12">
                    <div class="panel">
                        <p><asp:Label Text='<%# Eval("story_title") %>' runat="server" ID="story_titleLabel" /></p> 
                    </div>
                </div>
            </div>
    </ItemTemplate>
    <LayoutTemplate>
        <div runat="server" id="itemPlaceholderContainer" style=""><span runat="server" id="itemPlaceholder" /></div>
        <div style="">
        </div>
    </LayoutTemplate>
</asp:ListView>

任何幫助,將不勝感激。

一種可能性是在頁面上添加隱藏的輸入服務器控件,並在設置“數據順序”屬性的值時動態設置該隱藏的輸入的值。 然后,只要隱藏的服務器控件在表單中,就可以在提交表單時輕松地從背后的代碼(因為它是服務器控件)中獲取隱藏的輸入的值。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM