tags:

views:

49

answers:

1
  <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 :/

+2  A: 

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.

Arkain
ok..lemme try..thnx
Serenity
@Happy Soul, did you find a solution?
Arkain
hv removed the divs and set the values as 950px for btn1's td and 400px fo the 2nd btn..the buttons appear alright on my page no matter if one button gets displyed dynamically or both do...now won't the buttons appear differently when some user using a PC of bigger or smaller resolution runs this page??..oh and I also had to set align as centre for both td tags
Serenity
@Happy Soul, the button will appear at the same place regardless of screen resolution but by using fixed sizes you are designing for a particular resolution, if you want a liquid design you can use percentages instead, like width="20%". Making a liquid design is a lot of work however, http://www.mardiros.net/liquid-css-layouts.html.
Arkain
@Happy Soul, did it solve you problem?
Arkain
it did..thnx...
Serenity