I am using DataList control to show three products per line horizontally. But there is layout problem and it pushes up the product image container element like the below :
Data List Layout problem http://www.pixelshack.us/images/wwmlzkvhxsr7b2l0ptcl.jpg
Here is the code :
<asp:DataList ID="dlProducts" runat="server" RepeatColumns="3" RepeatLayout="Table"
DataSourceID="ObjectDataSourceCategories" RepeatDirection="Horizontal" CellSpacing="10" CellPadding="0" HorizontalAlign="Center" ItemStyle-Wrap="true">
<ItemTemplate>
<a href='<%# "Items.aspx?catId=" + (string)Eval("id") %>'>
<asp:Image ID="Image1" CssClass="photo-border photo-float-left" runat="server" Width="165px"
Height="120px" ImageUrl='<%# "ProductImages/Thumbnails/" + (string)Eval("ImageUrl") %>'
AlternateText='<%#(string)Eval("ImageAltText")%>' /></a>
<br />
<asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='<%# "Items.aspx?catId=" + (string)Eval("id") %>'
Text='<%# Eval("Title").ToString()%>' Font-Bold="true" />
</ItemTemplate>
</asp:DataList>
How can I get over the problem ?
Thanks in advance.
I was having a similar issue. I ended up having to break the linked image and and text into their own div and style them accordingly:
<ItemTemplate>
<div class="outer">
<div class="top">
<asp:HyperLink id="hlImage" runat="server" CssClass="Font7">
</asp:HyperLink>
</div>
<div class="bottom">
<asp:Label id="lbText" runat="server" CssClass="Font7"></asp:Label>
</div>
</div>
</ItemTemplate>
I'm sure there are cleaner ways to do this and this is just example of what the HTML output might look like. This is just "off the cuff" but if you put in an empty htm file it will display.
<div style="width: 100px;">
<!-- first row -->
<div style="float:left; width:50px; border: 2px solid black;">
<div>
link
</div>
<div style="height:50px; background-color:Aqua; vertical-align:bottom;">
<span>text</span>
</div>
</div>
<div style="float:left; width:50px; border: 2px solid black;">
<div>
link
</div>
<div style="background-color: Aqua;">
<span style="height:50px; vertical-align:bottom;">text</span>
</div>
</div>
<!-- second row -->
<div style="float:left; width:50px; border: 2px solid black;">
<div>
link
</div>
<div style="height:50px; background-color:Aqua; vertical-align:bottom;">
<span>text</span>
</div>
</div>
</div>
You can most likely use RepeatLayout="Flow" ItemStyle="float:left;" in your DataList control to help as well.
I'm not sure off the top of my head how to fix this, but I would start by putting each item in a <div> or <span> and use CSS classes, instead of the control's styling. E.g.:
<Item Template>
<div class="myClass">...</div>
</Item Template>
Using this with Firebug to then debug is usually easier than figuring out how you're violating the control's height, etc.
Related
I have used asp's repeater to repeat 3 images per row but it shows only 1 image per row. why ?
I have tried every way I could but no effect.
<asp:Repeater ID="rptrImages" runat="server">
<ItemTemplate>
<div class="row">
<div class="col-md-4">
<div class="thumbnail">
<img src='<%# "UploadedImages/"+ Eval("Image") %>' alt="No Image" class="img-responsive img-rounded" />
</div>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
The <ItemTemplate> within a repeater is the content that gets repeated for every object within the data source. All you need to do is refactor your template:
<div class="row">
<asp:Repeater ID="rptrImages" runat="server">
<ItemTemplate>
<div class="col-md-4">
<div class="thumbnail">
<img src='<%# "UploadedImages/"+ Eval("Image") %>' alt="No Image" class="img-responsive img-rounded" />
</div>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
Using the above, the <div class="col-md-4"> will be repeated for each item in your data source and all contained within a single <div class="row">, due to the nature of Bootstrap's columns they will automatically wrap onto another line within the same div once three are placed horizontally. If you need to hide the <div class="row"> should the repeater not contain any items then try the below:
<asp:Repeater ID="rptrImages" runat="server">
<HeaderTemplate>
<div class="row">
</HeaderTemplate>
<ItemTemplate>
<div class="col-md-4">
<div class="thumbnail">
<img src='<%# "UploadedImages/"+ Eval("Image") %>' alt="No Image" class="img-responsive img-rounded" />
</div>
</div>
</ItemTemplate>
<FooterTemplate>
</div>
</FooterTemplate>
</asp:Repeater>
Then in your code-behind when binding the repeater:
rptrImages.DataSource = myDataSourceVar;
rptrImages.DataBind();
rptrImages.Visible = (rptrImages.Items.Count > 0);
Because the <div class="row"> is within the HeaderTemplate and FooterTemplate it will not get rendered if you set Visible to false.
You must add width and height to Your Image
<div class="row" style="width: 100%;">
<div class="col-sm-12">
<asp:Repeater ID="RepeaterImages" runat="server" Visible="true">
<ItemTemplate>
<asp:Image ID="imageSlide" CssClass="MyGridGallery" ImageUrl='<%# Container.DataItem %>' runat="server" Width="300px" Height="200px" />
</ItemTemplate>
</asp:Repeater>
</div>
.MyGridGallery {
padding: 5px;
}
</style>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div id="divFilters">
<div class="subHeaderWrapper">
<span class="subHeaderLeft">
<img id="imgCtrlContainer" onclick="toggle_visibility('divContainer1','imgCtrlContainer','span_min.png','span_max.png','true');" name="Expand and Collapse1" alt="Expand / Collapse" src="../Style/UX/Images/span_min.png" style="display: none;" />
</span>
<span class="widgtTitle">
<asp:Label ID="lblFilters" EnableTheming="false" runat="server" Text="Filters"></asp:Label>
</span>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<div class="subHeaderWrapper" id="divSubHeaderWrapper" runat="server">
<span class="subHeaderLeft"></span>
<span class="widgtTitle">
<asp:Label ID="lblObservation" EnableTheming="false" runat="server" Text="Observation"></asp:Label>
</span>
<a **href="#divFilters"** id="filterAnchor" class="filtersPopup" style="text-decoration: none;">
<img style="border-bottom: medium none; border-left: medium none; border-top: medium none; border-right: medium none" id="util1" class="filterIcon" onmouseover="mouseOverUtl('util1')" title="Filter" onmouseout="mouseOutUtl('util1')" name="Util1" runat="server" alt="Utility" src="../Images/icon_dash_filters.png" />
</a>
</div>
<asp:Griview...>
</asp:Gridview>
Above is my code written in the asp:UpdatePanel tag.While going from the anchor tag to the div "divFilter" the href="#divFilters" mentioned is not working.The same page when taken to another aspx page without giving updatepanel works fine. But I need to get it done under UpdatePanel only
I use JQuery ThickBox 3.1 , and here is my code
<telerik:RadListView runat="server" ID="myDataList" AllowPaging="true"
DataKeyNames="id" ItemPlaceholderID="PlaceHolder1"
NeedDataSource="list_DataRebind">
<LayoutTemplate>
<div class="sushibar">
<asp:Panel ID="SushiPanel" runat="server">
<div class="sushi">
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
</div>
<telerik:RadDataPager ID="RadDataPager1" runat="server" PageSize="4" PagedControlID="myDataList">
<Fields>
<telerik:RadDataPagerButtonField />
<telerik:RadDataPagerPageSizeField />
<telerik:RadDataPagerSliderField />
</Fields>
</telerik:RadDataPager>
</asp:Panel>
</div>
</LayoutTemplate>
<ItemTemplate>
<div class="imageDiv">
<span style="margin-bottom: 5px; display: block; color: #FF6600; font-weight: bold;">
<%#Eval("Title") %></span>
<br />
<a href='<%#Eval("ImagePath")%>' title='<%#Eval("Title")%>' class="thickbox" >
<img src='<%#Eval("ImagePath")%>' alt="Single Image" width="150px" height="200px" /></a></div>
</ItemTemplate>
</telerik:RadListView>
Popup box with Image and Title show correctly , but I have another field(<%#Eval("Description")%>) to show with it !
I found how to show Inline Content in Thickbox ,
<input alt="#TB_inline?height=300&width=400&inlineId=myOnPageContent" title="add a
caption to title attribute / or leave blank" class="thickbox" type="button" value="Show" />
<a href="#TB_inline?height=155&width=300&inlineId=hiddenModalContent&modal=true"
class="thickbox">Show hidden modal content.</a>
But I don't know how to use this in a ListView !
:D , I found the answer ! Just put the contents ( Image + Description ) to hidden division (style with Display:none) and set this div id to inlineId .
<ItemTemplate>
<div class="imageDiv">
<span style="margin-bottom: 5px; display: block; color: #FF6600; font-weight: bold;">
<%#Eval("Title") %></span>
<br />
<div id="popUpRegion" style="display: none">
<img src='<%#Eval("ImagePath")%>' alt="Single Image" width="500px" height="600px" />
<p>
<%#Eval("Description")%></p>
</div>
<a href="#TB_inline?height=800&width=600&inlineId=popUpRegion" title='<%#Eval("Title")%>'
class="thickbox">
<img src='<%#Eval("ImagePath")%>' alt="Single Image" width="150px" height="200px" /></a></div>
</ItemTemplate>
I have the following code in ASP.NET.
The problem is that this HyperLink(hpRecord) works for all surface of "posts_listDiv" other than the two images which are not clickable in IE 9.
I tested that code and works fine in all browsers other than Internet Explorer.
<asp:Repeater ID="RepeaterCategories" runat="server">
<ItemTemplate>
<asp:HyperLink ID="hpRecord" runat="server" NavigateUrl='link'>
<div id="posts_listDiv" class="posts_listDiv">
<div id="pict1Div" class="pict1Div">
<asp:Image ID="picture" runat="server" Width="100px" Height="80px" ImageUrl='link'/>
</div>
<div id="pict2Div" class="pict2Div">
<asp:Image ID="pict2" runat="server" Width="100px" Height="80px" ImageUrl='link'/>
</div>
<div id="detailsDiv" class="detailsDiv">
<%--text--%>
<%# Eval("...")%>
<br />
<%--by user--%>
<i style="color:blue"><%# Eval("FirstName") %> </i>
</div>
</div>
</asp:HyperLink>
</ItemTemplate>
</asp:Repeater>
and this is CSS for "posts_listDiv":
.posts_listDiv
{
background-color:red;
margin-left:5px;
float:left;
width:232px;
height:171px;
word-wrap: break-word;
font-size:14px;
margin-left:8px;
margin-top:10px;
}
Add a style to "posts_listDiv" parent div.
.parent {
display: block;
}
I have an ASP.NET 3.5 form with several fields and a sub form inside a ModalPopup. The problem I'm having is with a RequiredFieldValidator inside the ModalPopup. For some reason it is preventing post back inside the ModalPopup. Both the validator and the submit buttons have the same ValidationGroup that is unique to them. Here is the markup for the sub form:
<%# Control Language="C#" AutoEventWireup="true" CodeFile="RoomBuilder.ascx.cs" Inherits="Admin_Controls_RoomBuilder" %>
<link href="../../../../style/FlexStyle.css" rel="stylesheet" type="text/css" id="style"
runat="server" visible="false" />
<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div class="form" style="width: 420px; height: 500px; padding: 3px; position: relative;
text-align: center;">
<div style="width: 280px">
<div class="item smalltitle ">
Title:
</div>
<div class="item">
<asp:TextBox ID="txtTitle" runat="server" Width="250px"></asp:TextBox>
</div>
<div class="item smalltitle gapontop">
Description:
</div>
<div class="item">
<asp:TextBox ID="txtDesc" runat="server" Width="250px" Height="40px" TextMode="MultiLine"></asp:TextBox>
</div>
<div class="item gapontop">
<div class="smalltitle floatLeft" style="width: 120px;">
Room Number
</div>
<div class="smalltitle floatLeft" style="width: 120px;">
Phone
</div>
</div>
<div class="item">
<div class="floatLeft" style="width: 120px;">
<asp:TextBox ID="txtRoomNo" runat="server" Width="100px"></asp:TextBox>
</div>
<div class="floatLeft" style="width: 120px;">
<asp:TextBox ID="txtPhone" runat="server" Width="100px"></asp:TextBox>
</div>
</div>
<div class="item smalltitle gapontop ">
Type:
</div>
<div class="item">
<asp:TextBox ID="txtType" runat="server" Width="250px"></asp:TextBox>
</div>
<div class="item smalltitle gapontop ">
Number of Seats:
<asp:RequiredFieldValidator ID="RequiredFieldValidatortxtNoSeats" runat="server" ErrorMessage="*"
ControlToValidate="txtNoSeats" ValidationGroup="roomVal"></asp:RequiredFieldValidator>
</div>
<div class="item">
<asp:TextBox ID="txtNoSeats" runat="server" Width="50px"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Not a number"
ControlToValidate="txtNoSeats" ValidationGroup="roomVal" ValidationExpression="[0-9]*"></asp:RegularExpressionValidator>
</div>
</div>
<!-- ************************************ -->
<div class="topBorder" style="width: 100%; height: 35px; position: absolute; bottom: -8px;
right: 2px; text-align: right; padding-top: 11px;">
<asp:Button ID="btnCancel" runat="server" CssClass="button" Text="Cancel" CausesValidation="false"
OnClick="btnCancel_Click" ValidationGroup="roomVal" />
<asp:Button ID="btnSave" runat="server" CssClass="button" Text="Save" OnClick="btnSave_Click" CausesValidation="true" ValidationGroup="roomVal" />
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
When the validator is removed (or CausesValidation is set to false), the sub form posts. RegularExpressionValidators don't have this problem. I've run FireBug, but I'm not seeing any obvious errors.
Is there something I'm missing?
Oh my god I'm so stupid!! >:(
Found the reason for the problem. There was another copy of the same control nested inside another control. And (of course) having the same ValidationGroup name as my first control all Required Field Validators fail to work!
Argh! Candidate for a Daily WTF!
Sorry to have wasted everybody's time :(
Can you please check if your Button (or some other control) that open the popup and the modaldialog extender are outside the update panel?
I got strange problems with modalpopup too. I would suggest you to try something different, for example a numericupdown control from the ajaxcontroltoolkit, if you already use it. So you don't need any validator for this.
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<div class="item smalltitle gapontop ">
Number of Seats:
</div>
<div class="item">
<asp:TextBox ID="txtNoSeats" runat="server" Width="50px"></asp:TextBox>
<cc1:NumericUpDownExtender ID="txtNoSeatsExt" runat="server"
Enabled="true" Minimum="1" Maximum="100" TargetControlID="txtNoSeats" Width="50" />
</div>