Serenity
Serenity

Reputation: 5098

How do I fix the button's position?

<table>
    <tr>
        <td>
            <div style="margin-left: 220px;">
                <asp:Button ID="btn1" Text="Edit" CommandArgument='<%#Eval("UserID") %>'
                    CausesValidation="false" CommandName="Edit" Visible="false" runat="server" />
        </td>
        </div>
        <td>
            <div style="margin-left: 370px;">
                <asp:Button ID="btn2" Visible="false" Text="Edit" CommandArgument='<%#Eval("UserID") %>'
                    CausesValidation="false" CommandName="Edit" runat="server" />
            </div>
        </td>
    </tr>
</table>

The problem is when both buttons are made visible dynamically..the second button shifts right wards..how do I fix their position so they appear exactly where I want them ?

[edit] Do I need to use span or something instead of those divs ? IS there an HTML property that lets u fix a position of an element on page ? How do u do it ? I hv been googling but nothing came up..plz help

[edit 2] I just added position:fixed in style attribute in the two buttons..when I ran the code again..both buttons didn't even appear! how do u do it if not even this way ?

[edit 3]

I removed the divs and set both "td's" align property to centre..now the edit buttons are both appearing on the left together :/

Upvotes: 1

Views: 3779

Answers (1)

Jesper Fyhr Knudsen
Jesper Fyhr Knudsen

Reputation: 7937

Set a fixed width on the columns. Also you need to fix the ordering of your td and div tags

<table>
  <tr>
    <td width="200px">
      <asp:Button ID="btn1" Text="Edit" CommandArgument='<%#Eval("UserID") %>' CausesValidation="false" CommandName="Edit" Visible="false" runat="server" />
    </td>
    <td width="200px">
      <asp:Button ID="btn2" Visible="false" Text="Edit"    CommandArgument='<%#Eval("UserID") %>' CausesValidation="false" CommandName="Edit" runat="server" />
    </td>
  </tr>
</table>

Will make the column 200px wide, just replace it with whatever width that suits your needs.

Edit: And well you don't really need the div tags for what you are doing.

Upvotes: 3

Related Questions