I am using a Telerik RadListView (the elements are the same in a standard ASP.NET ListView) to show some data from a database. I want to show them in a tiled layout, but it loads the items from left to right.
For example - if I have 4 items in a row, the 5th item is shown on the left side. I tried to add dir="rtl" to all divs but that doesn't work.
How can I make this load items from right to left?
Here is my code:
<telerik:RadListView ID="RadListView1" runat="server" AllowPaging="True" AllowCustomSorting="True" AllowMultiFieldSorting="True" AllowNaturalSort="True" DataKeyNames="product_key" DataSourceID="DS_pure_product" PageSize="12">
<LayoutTemplate>
<div class="RadListView RadListViewFloated RadListView_Default" dir="rtl">
<div class="container-fluid">
<div class="row">
<div class="col-md-6">
<telerik:RadDataPager ID="RadDataPager1" runat="server" SEOPagingQueryPageKey="CurrentPageKey" PageSize="12">
<Fields>
<telerik:RadDataPagerButtonField FieldType="FirstPrev" LastButtonImageUrl="" NextButtonImageUrl="" PrevButtonImageUrl="" />
<telerik:RadDataPagerButtonField FieldType="Numeric" LastButtonImageUrl="" NextButtonImageUrl="" PrevButtonImageUrl="" />
<telerik:RadDataPagerButtonField FieldType="NextLast" LastButtonImageUrl="" NextButtonImageUrl="" PrevButtonImageUrl="" />
<%--<telerik:RadDataPagerGoToPageField />
<telerik:RadDataPagerNumericPageSizeField />--%>
</Fields>
</telerik:RadDataPager>
</div>
<div class="col-md-3">
<table>
<tr>
<td>
</td>
<td>
</td>
</tr>
</table>
</div>
<div class="col-md-3">
</div>
</div>
</div>
<div class="rlvFloated">
<div class="container-fluid" dir="rtl" style="text-align:right;">
<div class="row">
<div id="itemPlaceholder" runat="server">
</div>
</div>
</div>
</div>
</div>
</LayoutTemplate>
<ItemTemplate>
<div class="rlvI col-md-3 lv_items">
<asp:Button ID="SelectButton" runat="server" CausesValidation="False" CommandName="Select" CssClass="rlvBSel" Text=" " ToolTip="Select" />
<table class="tbl_product">
<tr>
<td>
<asp:Image ID="Image2" CssClass="img-responsive img_product" runat="server" ImageUrl='<%# Eval("product_img") %>' />
</td>
</tr>
<tr>
<td>
<asp:Image ID="Image1" runat="server" CssClass="img_product_logo" ImageUrl='<%# Eval("product_brand") %>' />
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("product_name") %>' />
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("product_price") %>' />
</td>
</tr>
</table>
</div>
</ItemTemplate>
<EmptyDataTemplate>
<div class="RadListView RadListView_Default">
<div class="rlvEmpty">
There are no items to be displayed.</div>
</div>
</EmptyDataTemplate>
</telerik:RadListView>
After some conversation in the comments, it sounds like what you want is to right-align your content. In that case, float: right is what you're looking for.
The key is to have an overall container that will hold all of your data. Then, have another container for each row. This inner container is what you will float to the right. By not giving the inner container a width, it will grow to be as big as its children. If the inner container's width is less than that of its parent, it will show as aligning to the right side.
Below is an example of that.
.body {
height: 100px;
width: 500px;
background-color: red;
}
.child-container {
height: 100%;
float: right;
}
.child-1 {
height: 50%;
width: 100px;
float: left;
background-color: green;
}
.child-2 {
height: 50%;
width: 100px;
float: left;
background-color: orange;
}
.child-3 {
height: 50%;
width: 100px;
float: left;
background-color: blue;
}
<div class="body">
<div class="child-container">
<div class="child-1">
</div>
<div class="child-2">
</div>
<div class="child-3">
</div>
</div>
</div>
Related
When I open my aspx page I have 3 images horizontally side by side on desktop. But I want to open my page in mobile with these images aligned in center vertically. The content on the page should remain same except the images.
Aspx page
<div class="row enrollmentStep">
<div class="col-xs-12 step-container">
<!-- Top Container -->
<div class="row inner-step-container">
<div class="col-xs-12 top-spacing">
<div align="center" class="row">
<div id="pageDescription" class="col-xs-12" runat="server"></div>
</div>
<table align="center" border="0" cellpadding="3" cellspacing="0" width="100%">
<tr>
<div align="center">
<asp:Image ID="qrCodeImage" runat="server" Height="200px" Width="200px" Visible="true" />
</div>
<div align="center">
<a id="secret" runat="server" class="txtLabel" visible="true" target="_blank"></a>
<td>
<div align="center">
<label id="siLabel" runat="server" for="siBox" class="txtLabel"></label>
</div>
</td>
</div>
</tr>
</table>
<div class="imgrow" align="center" visible="true">
<div class="top-spacing bottom-spacing" style="float: left; margin-left: 20%; margin-bottom: 0.5em; overflow:auto">
<a id="iTunesLink" runat="server" class="txtLabel" visible="true" target="_blank">
<asp:Image ID="itunes" Height="64px" Width="128px" runat="server" Visible="true" />
</a>
</div>
<div class="top-spacing bottom-spacing" style="float: left; align:center; margin-left: 20%; margin-bottom: 0.5em; overflow:auto">
<a id="play_storeLink" runat="server" class="txtLabel" visible="true" target="_blank">
<asp:Image ID="play_store" Height="64px" Width="128px" runat="server" Visible="true" />
</a>
</div>
<div class="top-spacing bottom-spacing" style="float: left; margin-left: 20%; margin-bottom: 0.5em; overflow:auto">
<a id="windows_storeLink" runat="server" class="txtLabel" visible="true" target="_blank">
<asp:Image ID="windows_store" Height="64px" Width="128px" runat="server" Visible="true" />
</a>
</div>
</div>
</div>
</div>
</div>
</div>
I've read that the ListView itself can't take CSS to adjust its width, but that you do it in the ItemTemplate, but I just can't get it. I'm trying to put three ListView controls side by side. Each control has an image and text to the right. Think Windows Explore file list, but only a single column with a name.
The text in each ListView will be less than 32 characters, so there should be plenty of room, but each ListView takes up more than 50% of the screen no matter what I've tried. CSS is not my strong suit.
Current CSS which is wrong
.lv_table{
width:500px;
border: 1px solid #ccc;
}
.lv_tr
{
width: 100px;
}
.list_view
{
border-style: solid;
border-width: 2px;
border-color: #000000;
}
.list_image
{
float: left;
display: inline-block;
}
.list_item_large
{
font-size: 1.6em;
color: #000000;
padding: 8px 0px 0px 0px;
margin: 0px auto;
display: inline-block;
text-align:left;
min-height: 32px;
}
ListView Controls
<table class="lv_table">
<tr class="lv_tr"><td class="list_view">
<asp:ListView runat="server" ID="lvwCategories" >
<LayoutTemplate>
<div style="width: 500px;">
<asp:PlaceHolder runat="server" ID="itemPlaceholder" />
</div>
</LayoutTemplate>
<ItemTemplate>
<div class="list_image">
<img alt="" src='<%# "Styles/Images/" + Eval("category_icon") %>' height="32" width="32" />
</div>
<div class="list_item_large ">
<a href='sCategories.aspx?cat_id=<%# Eval("category_id")%>'><%# Eval("Cat_title")%></a>
</div>
</ItemTemplate>
<ItemSeparatorTemplate>
<div>
</div>
</ItemSeparatorTemplate>
<EmptyDataTemplate>
<div>
<img alt="" src="Styles/Images/ic_lw.png" height="48" width="48" />
</div>
<div>
<b>No Categories Found</b>
</div>
</EmptyDataTemplate>
</asp:ListView>
</td>
<td> </td>
<td class="list_view">
<asp:ListView runat="server" ID="lvwLists">
<LayoutTemplate>
<div style="width: 500px;">
<asp:PlaceHolder runat="server" ID="itemPlaceholder" />
</div>
</LayoutTemplate>
<ItemTemplate>
<div class="list_image">
<img alt="" src='<%# "Styles/Images/" + Eval("category_icon") %>' height="32" width="32" />
</div>
<div class="list_item_large ">
<a href='sCategories.aspx?cat_id=<%# Eval("category_id")%>'><%# Eval("Cat_title")%></a>
</div>
</ItemTemplate>
<ItemSeparatorTemplate>
<div>
</div>
</ItemSeparatorTemplate>
<EmptyDataTemplate>
<div>
<img alt="" src="Styles/Images/ic_lw.png" height="48" width="48" />
</div>
<div>
<b>No Categories Found</b>
</div>
</EmptyDataTemplate>
</asp:ListView>
</td>
<td> </td>
<td class="list_view">
<asp:ListView runat="server" ID="lvwItems">
<LayoutTemplate>
<div style="width: 500px;">
<asp:PlaceHolder runat="server" ID="itemPlaceholder" />
</div>
</LayoutTemplate>
<ItemTemplate>
<div class="list_image">
<img alt="" src='<%# "Styles/Images/" + Eval("category_icon") %>' height="32" width="32" />
</div>
<div class="list_item_large ">
<a href='sCategories.aspx?cat_id=<%# Eval("category_id")%>'><%# Eval("Cat_title")%></a>
</div>
</ItemTemplate>
<ItemSeparatorTemplate>
<div>
</div>
</ItemSeparatorTemplate>
<EmptyDataTemplate>
<div>
<img alt="" src="Styles/Images/ic_lw.png" height="48" width="48" />
</div>
<div>
<b>No Categories Found</b>
</div>
</EmptyDataTemplate>
</asp:ListView>
</td>
</tr>
</table>
You can change your .lv_table style width to 100% and give your .list_view style a width:33%; and remove all the inline width:500px; of your <div>'s in your LayoutTemplates.
This is my aspx code
<div id="tabs-1">
<table id="BookingTable" runat="server" class="tableResultClass">
<tr>
<th>ID</th>
<th>PlanTime</th>
</tr>
</table>
</div>
<div id="tabs-2">
<div id="circleG" style="margin-left: auto; margin-right: auto; padding-top: 50px; padding-bottom: 50px;">
<div id="circleG_1" class="circleG"></div>
<div id="circleG_2" class="circleG"></div>
<div id="circleG_3" class="circleG"></div>
</div>
</div>
<div id="tabs-3">
<p>
Date:
<input type="text" id="datepicker" runat="server">
</p>
<asp:ScriptManager ID="ScriptManager" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:Button ID="BookingForDate" runat="server" OnClick="BookingForDate_Click" Text="Search" />
<span style="color: red" id="errorDateMessage" runat="server"></span>
<div runat="server" id="circleG2" style="margin-left: auto; margin-right: auto; margin-left: 400px; padding-bottom: 60px;">
<div id="circleG_1" class="circleG"></div>
<div id="circleG_2" class="circleG"></div>
<div id="circleG_3" class="circleG"></div>
</div>
<table id="DateBookingTable" runat="server" class="tableResultClass">
<tr>
<th>ID</th>
<th>PlanTime</th>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</div>
It is simple code that have three div as tabs.
I want to know which tab is selected in a specific moment. how please?
I think it is something about session but I don't know what it is
You can do the following:-
1) Declare a global variable.
2) Attach a onClick event for each div. Whenever this event is fired, set this global variable with the id of corresponding div.
3) Access this global variable in the required function.
I have an ASP.NET control. I want to align the textbox to the right and the label to the left.
I have this code so far:
<td colspan="2">
<asp:Label ID="Label6" runat="server" Text="Label"></asp:Label>
<div style="text-align: right">
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</div>
</td>
The textbox aligns to the right, but the label aligns to the left and on the line above. How can I fix this so that the label is on the left, the textbox on the right, and both on the same line?
Thanks
you can use style
<td colspan="2">
<div style="float:left; width:80px"><asp:Label ID="Label6" runat="server" Text="Label"></asp:Label></div>
<div style="float: right; width:100px">
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</div>
<div style="clear:both"></div>
</td>
You should use CSS to align the textbox. The reason your code above does not work is because by default a div's width is the same as the container it's in, therefore in your example it is pushed below.
The following would work.
<td colspan="2" class="cell">
<asp:Label ID="Label6" runat="server" Text="Label"></asp:Label>
<asp:TextBox ID="TextBox3" runat="server" CssClass="righttextbox"></asp:TextBox>
</td>
In your CSS file:
.cell
{
text-align:left;
}
.righttextbox
{
float:right;
}
You can do it with a table, like this:
<table width="100%">
<tr>
<td style="width: 50%">Left Text</td>
<td style="width: 50%; text-align: right;">Right Text</td>
</tr>
</table>
Or, you can do it with CSS like this:
<div style="float: left;">
Left text
</div>
<div style="float: right;">
Right text
</div>
I've been goin at it now for an 1.5hrs and I just can't figure out a way to make it the way I want. I'm kind of new with all things web, and it takes about as much time (maybe more?) trying to get things where I want and doing it in a way that is elegant.
Anyways, I have two text boxes, with two labels above them and centered over the box. I want to simply put a button in between them and about centered with the textboxes' height.
This is as close as I can make it get to what I want. I would like the left textbox moved over so it lines up with the words "Jump To:, "Customer:," and "Customer #:" and then have the right box be the same distance on the right with the Next button maybe a just 10px higher but still centered as it is. The problem with this picture is that it only works when the text boxes are shown and expanded, if they are hidden, then the panel actually renders half-way above the Customer # part because of how I manipulated the margins I'm guessing.
http://img192.imageshack.us/img192/259/controls.jpg http://img192.imageshack.us/img192/259/controls.jpg
Here's my attempt with <div>s
<div style="position:relative; overflow:auto; margin-top:15px; margin-bottom:10px;">
<div style="width:40%; float:left; margin-left:10px;">
<div><asp:Label runat="server" ID="lblInfoDesc" /></div>
<div><asp:TextBox ID="txtInfoDescription" runat="server" TextMode="MultiLine" Rows="3" MaxLength="500" Width="100%" /></div>
</div>
<%--<div style="position:absolute; margin-top:25px; margin-left:-10px;"><asp:Button ID="Button1" runat="server" Text="Next" /></div>--%>
<div style="width:40%; float:right; margin-right:16px;">
<div><asp:Label runat="server" ID="lblInfoData" /></div>
<div><asp:TextBox ID="txtInfoData" runat="server" TextMode="MultiLine" Rows="3" MaxLength="500" Width="100%" /></div>
</div>
</div>
And here's my attempt with table elements
<div style="margin-bottom:10px;">
<table style="position:relative; width:100%; margin-bottom:15px;">
<tr style="text-align:center";>
<td><asp:Label runat="server" ID="lblInfoDesc" /></td>
<td></td><td></td><td></td><td></td>
<td><asp:Label runat="server" ID="lblInfoData" /></td>
</tr>
<tr>
<td style="margin-left: 0px;"><asp:TextBox ID="txtInfoDescription" runat="server" TextMode="MultiLine" Rows="3" MaxLength="500" Width="80%" /></td>
<td></td><td></td><td></td><td></td>
<td style="margin-right:10px;"><asp:TextBox ID="txtInfoData" runat="server" TextMode="MultiLine" Rows="3" MaxLength="500" Width="80%" /></td>
</tr>
</table>
<div style="position:inherit; text-align:center; margin-top:-55px; margin-bottom:25px;">
<asp:Button ID="Button2" runat="server" Text="Next" />
</div>
</div>
All of those <td></td><td></td><td> was to attempt to put spaces between the button and the text boxes because I couldn't get float nor margin to work. Any help would be much appreciated!
And here's the complete page source:
<asp:Panel ID="pnlCustomer" runat="server" style="background-color:#ccccff; width:500px; height:90%; position:relative;" BorderColor="DarkBlue" BorderWidth="2px">
<div style="position:relative; margin-top:10px; margin-left:10px;">
<div style="color:#003399; font-size:18px; text-align:left;">Jump To:
<asp:DropDownList ID="ddlCategory" runat="server" AutoPostBack="True"
onselectedindexchanged="ddlCategory_SelectedIndexChanged"
style="margin-left:40px;"/>
</div>
</div>
<div style="position:relative; margin-top:10px; margin-left:10px;">
<div style="color:#003399; font-size:18px; text-align:left;">Customer:
<asp:DropDownList ID="ddlCustomersList" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="ddlCustomersList_SelectedIndexChanged"
style="margin-left:35px;"/>
<asp:Button ID="btnAddCustomer" runat="server" Text="Add" OnClick="btnAddCustomer_Click" OnClientClick="return confirm('Warning: This will redirect you from the page');" />
</div>
</div>
<div style="position:relative; margin-top:10px; margin-left:10px;">
<div style="color:#003399; font-size:18px; text-align:left;">Customer #:
<asp:DropDownList ID="ddlCustomerNumber" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="ddlCustomerNumber_SelectedIndexChanged"
style="margin-left:20px;"/>
<asp:TextBox ID="txtCustomerNumber" runat="server" style="margin-left:20px;" />
<asp:Button ID="btnModify" runat="server" Text="Modify" OnClick="btnModify_Click" />
<asp:Button ID="btnCreateNew" runat="server" Text="Create New" OnClick="btnCreateNew_Click" />
<asp:Button ID="btnUpdate" runat="server" Text="Update" OnClick="btnUpdate_Click" />
<asp:Button ID="btnDelete" runat="server" Text="Delete" OnClick="btnDelete_Click" OnClientClick="return confirm('Do you want to delete the record ?');" />
<asp:Button ID="btnSaveNew" runat="server" Text="Save" OnClick="btnSaveNew_Click" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClick="btnCancel_Click" />
</div>
</div>
<%-- <div style="margin-bottom:10px;">
<table style="position:relative; width:100%; margin-bottom:15px;">
<tr style="text-align:center";>
<td><asp:Label runat="server" ID="lblInfoDesc" /></td>
<td></td><td></td><td></td><td></td>
<td><asp:Label runat="server" ID="lblInfoData" /></td>
</tr>
<tr>
<td style="margin-left: 0px;"><asp:TextBox ID="txtInfoDescription" runat="server" TextMode="MultiLine" Rows="3" MaxLength="500" Width="80%" /></td>
<td></td><td></td><td></td><td></td>
<td style="margin-right:10px;"><asp:TextBox ID="txtInfoData" runat="server" TextMode="MultiLine" Rows="3" MaxLength="500" Width="80%" /></td>
</tr>
</table>
<div style="position:inherit; text-align:center; margin-top:-55px; margin-bottom:25px;">
<asp:Button ID="Button2" runat="server" Text="Next" />
</div>
</div>--%>
<div style="position:relative; overflow:auto; margin-top:15px; margin-bottom:10px;">
<div style="text-align:center; margin-bottom:-20px; ">
<asp:Button ID="btnNextInfo" runat="server" Text="Next" />
</div>
<div style="width:40%; float:left; margin-left:10px;">
<div><asp:Label runat="server" ID="lblInfoDesc" /></div>
<div><asp:TextBox ID="txtInfoDescription" runat="server" TextMode="MultiLine" Rows="3" MaxLength="500" Width="100%" /></div>
</div>
<div style="width:40%; float:right; margin-right:16px;">
<div><asp:Label runat="server" ID="lblInfoData" /></div>
<div><asp:TextBox ID="txtInfoData" runat="server" TextMode="MultiLine" Rows="3" MaxLength="500" Width="100%" /></div>
</div>
</div>
<div style="margin-top:-20px; position:absolute; font-size:12px;"><asp:Label runat="server" ID="lblErrorMessage" /></div>
</asp:Panel>
It seems like this is more of a CSS and HTML question than an ASP.Net question.
To be clear, centering things vertically in their parent with CSS isn't easy, the trick is:
The parent element must have a position:relative or absolute.
The child must be wrapped in a div or something positionable.
The child must have the top:50%
The child must declare a height.
the child must have a margin-top = it's height / 2 * -1. (basically you move it up by half it's height.)
Try this:
<style>
div.textboxArea {
text-align:center;
float:left;
width:40%;
height:400px;
}
.textboxArea textarea {
width:80%;
height:400px;
}
.centerMeVertically div {
position:absolute;
top:50%;
vertical-align:middle;
height:30px;
width:100%;
margin-top:-15px;
text-align:center;
}
div.centerMeVertically {
float:left;
width:20%;
text-align:center;
height:400px;
position:relative;
}
p {
height:35px;
margin:-35px 0 0 0;
}
.container {
margin-top:35px;
}
</style>
<div class="container">
<div style="width:100%;">
<div class="textboxArea">
<p>Label 1</p>
<textarea></textarea>
</div>
<div class="centerMeVertically">
<div><button>Button2</button></div>
</div>
<div class="textboxArea">
<p>Label 2</p>
<textarea></textarea>
</div>
</div>
</div>
EDIT: Having seen your revised question, I've revised my answer to center the button only to the textarea vertically.
You have to do some stupid CSS tricks with the top-margin, but it gets the job done. Also notice the container div. This is to make sure that if you place anything "above" this snippet in your markup, it doesn't get overlapped by the labels.
if I haven't misunderstood, it's not that tough. see if following code renders the layout your image says.
<table cellpadding="3px" cellspacing="0" border="0" style="width: 100%;">
<tr>
<td align="center" valign="top">
Label
</td>
<td align="center" valign="top">
</td>
<td align="center" valign="top">
Label
</td>
</tr>
<tr>
<td align="center" valign="top">
<asp:TextBox ID="TextBox1" TextMode="MultiLine" Rows="7" runat="server"></asp:TextBox>
</td>
<td align="center" valign="top">
<asp:Button ID="Button1" runat="server" Text="Button" />
</td>
<td align="center" valign="top">
<asp:TextBox ID="TextBox2" TextMode="MultiLine" Rows="7" runat="server"></asp:TextBox>
</td>
</tr>
</table>
I would stick with something simple like this table... then add padding as needed.
<table>
<tr>
<td align="center">label a</td>
<td></td>
<td align="center">label b</td>
</tr>
<tr>
<td valign="top"><textarea id="txtinfodescription" rows="3" maxlength="500" width="80%"></textarea></td>
<td valign="middle"><input type="button" id="button2" value="next"/></td>
<td valign="top"><textarea id="txtinfodata" rows="3" maxlength="500" width="80%"></textarea></td>
</tr>
</table>
don't get me wrong, you can go the pure CSS route too... but if you layout get much more complex and you need to maintain a fairly rigid "grid-like" structure... tables help.