开发者

Control Layout Template

I need a way to layout controls in a page. Let me ask you by example.

I have four different action buttons (Edit, Delete, etc..) that do the same actions on any page, but sometimes I want them laid out horizontally and some other times vertically, depending on which page is displaying them.

So I thought of placing all four buttons in a user control and manage their layout using some sort of template control.

Does such a control exist that is as flexible as ListView's template management?

Of course a lazy solution is to place four 开发者_如何学Cbuttons horizontally in a panel, and another four buttons vertically in another panel, and show/hide the panel that's requested, but I don't want to have two instances of the buttons; I just want one instance of each button, but in different layouts.

Feel free to add more tags to this.


Such thing can be achieved with CSS. I'm bad in CSS but I believe this works:

HTML

<div class="horizontal">
    <input type="button" value="1" />
    <input type="button" value="2" />
    <input type="button" value="3" />
    <input type="button" value="4" />
</div>

Two CSS classes you simply set which you need in the div element (you can wrap your buttons with UserControl and map div's class to UserControl's property)

  <head>
    <style type="text/css">
        .horizontal input 
        {
            margin:0px 2px 0px 2px;
        }

        .vertical input
        {
            display:block;
            margin:2px 0px 2px 0px;
        }
    </style>
  </head>

Templated control is to strong for such easy task especially when you do not need to change template content.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜