<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 :/
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.
Related
I have a Repeater with 2 LinkButtons that need to be displayed next to each other to build a graphical unit. Depending on the window size the line break would break that unit. How can I tie these 2 elements together? I was fiddling with div but the result was that each result of the repeater is displayed in a new row, while I need them to be displayed horizontal.
<asp:Repeater runat="server" id="RepeaterUsers" >
<ItemTemplate>
<div style="display:inline;">
<div style="white-space:nowrap;">
<asp:LinkButton ID="LB1" runat="server" OnClick="SelectUser"><asp:Label runat="server" Text='<%# Bind("Name") %>' ID="RepeaterName"/>
</asp:LinkButton><asp:LinkButton ID="LB2" runat="server" OnClick="EliminateUser"><img src="img/close33.png"></asp:LinkButton></div><asp:Label runat="server" Text=" " Height="24px" ID="LabelSpace"/></div>
</ItemTemplate>
</asp:Repeater>
The final solution is:
<asp:Repeater runat="server" id="RepeaterUsers" >
<ItemTemplate>
<div style="float:left">
<table class="RepeaterTable">
<tr>
<td class="RepeaterTD">
<asp:LinkButton ID="ButtonHWReminderAudit" runat="server" OnClick="SelectUser" Font-Size="11px" CommandArgument='<%# Bind("Name") %>' CssClass='<%# Eval("CSSName") %>' ><%# Eval("DisplayName") %></asp:LinkButton></td>
<td class="RepeaterTD">
<asp:LinkButton ID="LinkButton4" runat="server" CommandArgument='<%# Bind("Name") %>' OnClick="EliminateUser" Font-Size="11px" CssClass='<%# Eval("CSSX") %>'>
<img src="img/close33.png" border="0" style="vertical-align:text-bottom;height:21px"></asp:LinkButton></td>
<td class="RepeaterTD">
<asp:Label runat="server" Text=" " Height="25px" ID="LabelSpace"/></td>
</tr>
</table>
</div>
</ItemTemplate>
</asp:Repeater>
and CSS:
.RepeaterTable {border-spacing:0;border-collapse:collapse;float:left;}
.RepeaterTD {padding: 0px;}
The column "Name" carries white spaces which occasionally might lead to a line break within one cell. Therefore I had to replace whitespace with a non-breakable-space (nbsp;) first.
In order to avoid gaps between the cells, you have to set spacing and padding to 0. This would provoke that no distance is kept between the tables. To set horizontal and vertical distances I added an additional cell.
I think you are looking for float: left
<asp:Repeater runat="server" ID="RepeaterUsers">
<ItemTemplate>
<div style="float: left; margin-bottom: 24px; clear: both">
<asp:LinkButton ID="LB1" runat="server"><%# Eval("Name") %></asp:LinkButton>
<asp:LinkButton ID="LB2" runat="server"><img src="img/close33.png"></asp:LinkButton>
</div>
</ItemTemplate>
</asp:Repeater>
Update
You could also use a table to align items, that always works. Although that is a bit old-school and against HTML-purists.
<table cellspacing="0" cellpadding="3" border="0">
<asp:Repeater runat="server" ID="RepeaterUsers">
<ItemTemplate>
<tr>
<td>
<asp:LinkButton ID="LB1" runat="server"><%# Eval("Name") %></asp:LinkButton>
</td>
<td>
<asp:LinkButton ID="LB2" runat="server"><img src="img/close33.png"></asp:LinkButton>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
So, the reason for my disturbance, I need to put these TextBoxes, Labels, Buttons in a pretty line among themselves.
For some of you this might be easy doing in CSS, so please help me :D
Any reference where I can read about it would be nice too.
Extra Info:
Website is based on ASP.NET
EDIT1:
<asp:RadioButtonList ID="radioListRight" runat="server" AutoPostBack="True" RepeatDirection="Horizontal" >
<asp:ListItem>Recht hinzufuegen</asp:ListItem>
<asp:ListItem>Recht entfernen</asp:ListItem>
</asp:RadioButtonList>
<asp:Label ID="LabelError" runat="server" Font-Bold="True" Font-Size="Large" ForeColor="Red"></asp:Label>
<br />
Projekt: <asp:DropDownList ID="comboProj" runat="server" AutoPostBack="True" Width="140px" Visible="False">
</asp:DropDownList><br />
Teilprojekt: <asp:DropDownList ID="ComboTP" runat="server" Width="136px" Visible="False">
</asp:DropDownList>
<asp:Button ID="btnAddTP" runat="server" Text="Hinzufügen" Visible="False" />
<br />
<asp:ListBox ID="ListBoxTP" runat="server" Height="164px" Width="422px" Visible="False"></asp:ListBox><br />
Art der Berechtigungen:
<asp:DropDownList ID="comboBerechtigungsArt" runat="server" Visible="False" AutoPostBack="True">
<asp:ListItem>Auswählen...</asp:ListItem>
<asp:ListItem Value="CHECK-IN / CHECK-OUT"></asp:ListItem>
<asp:ListItem>CHECK-OUT</asp:ListItem>
<asp:ListItem>CHECK-IN</asp:ListItem>
</asp:DropDownList><br />
Berechtigungen eintragen für <asp:TextBox ID="TextBoxUser" runat="server" Width="151px" placeholder="HendrikHeim" Visible="False"></asp:TextBox>
<asp:Button ID="btnAddUser" runat="server" Text="Hinzufügen" Visible="False" />
<br />
<asp:Label ID="labelEmail" runat="server" Text="EMail"></asp:Label>
Don't use tables, use CSS and 'div' nodes to wrap the content and the display style to put the data inline.
Use http://www.w3schools.com/
As a source for CSS
Tables will not flow correctly if the browser width is to narrow, putting into individual tags will allow the browser to style the layout correctly.
To put elements on the same row:
<div style="display:inline;width:80px;">content here</div>
<div style="display:inline;width:100px;">content here</div><br />
You can then fix the width of the columns by adding more styles, width etc.
If you are unfamiliar with CSS, then spend some time learning it.
I am having lot of space between newly added radiobuttons(yes and No) of the RadioButtonList and the first part of the existing region(divName) is aligned properly.
can any body help me in aligning the newly added second region(div1)
<div id="divpanelFacts" runat="server">
<fieldset id="panelFacts">
<table width="100%">
<tr>
<td>
<div id="divName" runat="server" visible="false">
<span>
<label runat="server" id="Label1">
<span id="pNameSpan" runat="server">*</span>P Name</label>
<asp:TextBox ID="textPName" runat="server" MaxLength="20"></asp:TextBox>
</span>
</div>
</td>
<td>
<div id="div1" runat="server" visible="false">
<asp:Label ID="lbl1" runat="server" Text="Would like to use this option for document purpose"></asp:Label>
<asp:RadioButtonList ID="rbl1" runat="server" TextAlign="Left" RepeatDirection="Horizontal">
<asp:ListItem Value="Yes" Text="Yes" />
<asp:ListItem Value="No" Text="No" Selected="True" />
</asp:RadioButtonList>
</div>
</td>
</tr>
</table>
</fieldset>
</div>
Your table width is at 100%, which means it's going to stretch it, and table I think takes precedence.
I have a popup window which has a multiline textbox with 2 buttons under that. A Cancel and a Save.
I have:
<div style="width: 650px;">
<div style="padding-top: 10px; text-align: center">
<asp:TextBox ID="TxtTest" Width="530px" TextMode="MultiLine" Style="word-wrap: break-word; height: 200px; overflow: auto; vertical-align: top" runat="server" AutoComplete="off" />
<asp:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender2" WatermarkCssClass="textwatermarkNotes" TargetControlID="TxtOther" WatermarkText="Please enter a message here..." runat="server" />
</div>
<div style="margin-top: 10px; margin-bottom: 10px; text-align: center;">
<asp:Button ID="BtnCancel" OnClick="btnCancel_click" CssClass="buttonSmall" CausesValidation="false" Text="Cancel" runat="server" OnClientClick="EncodeText()" />
<asp:Button ID="BtnSave" runat="server" CssClass="buttonSmall" Text="Save" OnClick="btnSave_Click" />
</div>
<div>
<asp:Label Width="130px" ID="txtCharMax" Text="" runat="server" />
</div>
</div>
I have in the code-behind to say like "100 character max". But I want the Cancel and Save centered and the "100 character max" to the right of the Save.
On the 4th DIV I thought I could do something like:
<div style="float:left">
<asp:Label Width="130px" ID="txtCharMax" Text="">
</div>
But that didn't work.
What is the best/easiest way to do this? Leaving CSS out but using the Style tag?
Try something like this:
<div style="text-align: center;">
<button style="margin-left:100px">cancel</button>
<button>save</button>
<span style="display:inline-block;width:100px;">
TEXT
</span>
</div>
Making the text inline-block allows it to align alongside the buttons. Then giving it a width allows us to use margin-left on the left button to shunt it along right by the same amount so that the buttons appear centrally.
I'm experiencing some weird behaviour on my local machine, when I access a page on my test server everything is centered like I want. When I run the code on my local machine everything is left aligned, the centering is ignored.
The HTML is really simple so I don't see why this issue has suddenly started to happen.
<table>
<tr>
<td>
<asp:HyperLink NavigateUrl="" ID="hlPhoto" runat="server"><asp:Image ID="imgPhoto" runat="server" ImageUrl='<%# String.Format( "../images/mugshots/{0}", DataBinder.Eval(Container.DataItem,"Photo") )%>' /></asp:HyperLink>
</td>
</tr>
<tr>
<td valign="bottom" align="center">
<div>
<b>
<asp:Label ID="lblName" runat="server"><%# Eval("FullName")%></asp:Label></b> </div>
<div>
<asp:Label ID="Label1" runat="server"><%# Eval("Jobtitle")%></asp:Label></div>
<div>
<br />
<asp:HyperLink NavigateUrl="" ID="hlDetail" runat="server"><font size="2">Details</font></asp:HyperLink>
</div>
<div>
<asp:HiddenField ID="userID" runat="server" Value='<%# Eval("Jobtitle")%>' />
</div>
</td>