简体   繁体   English

动态将整数属性添加到服务器端控件

[英]Adding an integer property to server side control dynamically

this is my user control 这是我的用户控件

<site:videoAxis ID="player" PlayerType="BlogPage" Width="620" Height="348" runat="server"/> I want to add a control DefaultVid dynamically. <site:videoAxis ID="player" PlayerType="BlogPage" Width="620" Height="348" runat="server"/>我想动态添加控件DefaultVid。

what is the best way to add it? 最好的添加方式是什么?

Right now, I have it like this 现在,我有这样的

    <% if (ClipId > 0)
            { player.DefaultVid = ClipId;%>
        <site:videoAxis ID="player" PlayerType="BlogPage"  Width="620" Height="348" runat="server"/>

        <%
            } %>

It works correctly now. 现在它可以正常工作了。 But I don't think that is the best way to do it. 但是我认为这不是最好的方法。 Any suggestions? 有什么建议么?

IMHO, the technique you posted is a good way to do this, and is likely what I would have done. 恕我直言,您发布的技术是执行此操作的好方法,很可能是我会做的。 There is nothing wrong with it, and, based on its simplicity, alternative preferences would likely just be matters of opinion. 它没有任何问题,并且基于其简单性,替代偏好可能只是见解。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM