开发者

how to group the components to a fixed position on the screen in asp.net?

i am designing an registration page in asp.net.to group t开发者_StackOverflow中文版he components(label, ddl and text boxes) i am using panels,but while running the page positions of components are changing. How to fix components to a particular position?

thanks with regards, radha


You can use Table Tag For Example


better to add all the controls in a page to a table and set the table row and column position E.g:

<table style="width: 100%;">
            <tr>
                <td>
                    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                </td>
                <td>
                    <asp:Panel ID="Panel1" runat="server">
                        <table>
                        <tr>
                        <td>
                            <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label> 
                        </td>
                        <td>
                            <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                        </td>
                        <td>
                            <asp:DropDownList ID="DropDownList1" runat="server">
                            </asp:DropDownList>
                        </td>
                        </tr>
                        </table>
                    </asp:Panel>
                </td>
            </tr>

        </table>


I would suggest using the cssclass property of your panel element. An absurd example follows. (It still proves the concept)
<style type="text/css"> .pi { position:fixed;
top:100px;
left:100px;
height:100px;
background-color:Red;
width:1000px;
}
</style>
<asp:Panel ID="Panel2" CssClass="pi" runat="server">
<asp:TextBox ID="t1" runat="server" />
</asp:Panel>


Don't give up and use tables, for statically positioned elements I'll simply apply absolute positioning CSS, either to divs surrounding the elements or to the elements themselves:

.staticPosition
{
    position:absolute;
    top:20px;
    left:20px;
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜