Click here to Skip to main content
15,893,190 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Expert,


I am developing website and i am using vs.net 2008.

Now I am developing login details page.

and there are 5 Labels and 5 Textbox.and 2 Buttons

and i have put all controls in div,but

when i run the application they changes their position.

And i am not using table .

How i can set the effective design.

my design structure like this,

<div id="MainDiv">

<div id="DivTopHeader" style=" position:relative; z-index:2;">
//For Header and Menu bar </div> <div id="middle">
<div id="left"> Here I have to place all controls </div>
<div id="right">
For search and images</div> </div> </div>


Thanks in advance
Posted
Updated 29-Sep-11 1:59am
v2
Comments
hitech_s 29-Sep-11 7:25am    
use table then only you can get the design perfectly
BobJanova 29-Sep-11 7:53am    
Not true. Divs with absolute sizes will retain their dimensions. You should only use a table where the data is semantically tabular (though one might argue that a set of property-value label/<input> pairs is).
CodingLover 29-Sep-11 7:28am    
It depends on how you arrange the divs. Can you show us here.
udusat13 29-Sep-11 7:56am    
<div id="MainDiv">

<div id="DivTopHeader" style=" position:relative; z-index:2;">
//For Header and Menu bar
</div>

<div id="middle">

<div id="left">
Here I have to place all controls

</div>
<div id="right">For search and images</div>
</div>



</div>

XML
<div id="div1" runat="server" style="position: absolute; margin: -100px 0 0 -200px;top: 50%; left: 55%; background-color: White;">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="10">
       <tr>
            <td width="39%" align="right" valign="middle">
                <asp:label id="lable1" runat="server" text="Label1" xmlns:asp="#unknown" />
            </td>
            <td width="61%" align="left" valign="middle">
                 <asp:textbox id="TextBox1" runat="server" xmlns:asp="#unknown" />
            </td>
        </tr>
        <tr>
            <td width="39%" align="right" valign="middle">
                <asp:label id="Label2" runat="server" text="Label2" xmlns:asp="#unknown" />
            </td>
            <td width="61%" align="left" valign="middle">
                 <asp:textbox id="TextBox2" runat="server" xmlns:asp="#unknown" />
            </td>
        </tr>
        <tr>
            <td align="right" valign="middle">
                <asp:label id="Label3" runat="server" text="Label3" xmlns:asp="#unknown" />
            </td>
            <td align="left" valign="middle">
                <asp:textbox id="TextBox3" runat="server" xmlns:asp="#unknown" />
            </td>
        </tr>
        <tr>
            <td align="right" valign="middle">
                <asp:label id="Label4" runat="server" text="Label4" xmlns:asp="#unknown" />
            </td>
            <td align="left" valign="middle">
                <asp:textbox id="TextBox4" runat="server" xmlns:asp="#unknown" />
            </td>
        </tr>
        <tr>
            <td align="right" valign="middle">
                <asp:label id="Label5" runat="server" text="Label5" xmlns:asp="#unknown" />
            </td>
            <td align="left" valign="middle">
                <asp:textbox id="txtbox5" runat="server" xmlns:asp="#unknown" />
            </td>
        </tr>
        <tr>
            <td align="right" valign="middle">
                <asp:button id="btn1" runat="server" text="Button1" xmlns:asp="#unknown" />
            </td>
            <td align="left" valign="middle">
                
                <asp:button id="Button1" runat="server" text="Button2" xmlns:asp="#unknown" />
            </td>
        </tr>
    </table>
</div>
 
Share this answer
 
Comments
udusat13 29-Sep-11 8:34am    
Thanks for ur code.
Its working for me............
hitech_s 29-Sep-11 23:42pm    
ok
You can do something like this, below shown is just an example.Make necessary changes as per your requirements.

XML
<div style="width:100%">
<div style="width:45%;float:left">
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
<div style="width:45%;float:right">
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>

<div style="width:45%;float:left">
    <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
</div>
<div style="width:45%;float:right">
    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</div>
<div style="width:45%;float:left">
    <asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
</div>
<div style="width:45%;float:right">
    <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</div>
<div style="width:45%;float:left">
    <asp:Label ID="Label4" runat="server" Text="Label"></asp:Label>
</div>
<div style="width:45%;float:right">
    <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
</div>
<div style="width:45%;float:left">
    <asp:Label ID="Label5" runat="server" Text="Label"></asp:Label>
</div>
<div style="width:45%;float:right">
    <asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
</div>

</div>
 
Share this answer
 
Comments
udusat13 29-Sep-11 7:35am    
Thankssssssssssssss.
BobJanova 29-Sep-11 7:55am    
Using float will cause the items to jump onto two lines if the page can't accommodate both (i.e. if you make the window really narrow). This may be what is wanted, or it may not (in which case use one div per line and a <span> with a width set).

You should also put that style information into a CSS class for labels and text boxes, otherwise if you change the 45 you have to do it in 10 places.
udusat13 29-Sep-11 8:02am    
Thanksss,

Using table is better approch or div?
Please tell me,because my design side is week.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900