I am using DataList to show thumbnails, how can I use background-image url with eval
This code gives me The server tag is not well formed error.
<asp:DataList ID="DataListPortfolio" runat="server" RepeatColumns="3">
<ItemTemplate>
<asp:Image ID="ImageButton1" runat="server"
style="background-image: url('<%#Eval("featuredImagesSmall")%>');" />
</ItemTemplate>
</asp:DataList>
According to your comments, you probably just want to use a div instead of <asp:Image (which renders as an img), in order to achieve thumbnails that are all the same size regardless of the image size:
<asp:DataList ID="DataListPortfolio" runat="server" RepeatColumns="3">
<ItemTemplate>
<div style='width:100px;height:100px;background-position:center;background-image:url(<%# Eval("featuredImagesSmall") %>)'></div>
</ItemTemplate>
</asp:DataList>
I just put an arbitrary height and width on the div, but that will ensure all the thumbnails are the same size. You can play with the CSS to position the image inside the div.
Why not use the ImageUrl property of the ASP.NET Image control? Something like this:
<asp:DataList ID="DataListPortfolio" runat="server" RepeatColumns="3">
<ItemTemplate>
<asp:Image ID="ImageButton1" runat="server" ImageUrl='<%# Eval("featuredImagesSmall")%>' />
</ItemTemplate>
</asp:DataList>
Related
My asp code like this
<asp:Repeater ID="Repeater1" runat="server" Visible="true">
<ItemTemplate>
<asp:HyperLink ID="imgbtnHl" runat="server" Target="_blank"> // hyper link btn am givem target equal to blank but it is not working/
<asp:ImageButton runat="server" Width="300px"ID="imgbtnHospitalimg" ImageUrl=images/tt.png" />/while click the image i want new window not an popup/
</asp:HyperLink>
Don't use image button inside hyperlink instead of that use simple img tag.
referrer below code i have tested working fine.
<asp:Repeater ID="Repeater1" runat="server" Visible="true">
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server" Target="_blank" NavigateUrl="~/Default3.aspx" Text='<%# Eval("Name") %>'><img src="Good-mark.png" /></asp:HyperLink>
</ItemTemplate>
</asp:Repeater>
I want to palce a asp.net label over asp.net image
<asp:Image ID="Image1" runat="server" ImageUrl="~/option.PNG" />
<asp:Label ID="Label1" runat="server" Text="Labelsssssss"></asp:Label>
here it will come one after another only. I have to use both asp controls no html controls are allowed.How?
if possible, remove the image, put the label in a div, set the background-image of the div to your image.
<asp:Panel runat="server" ID="pnl">
<asp:Label runat="server" ID="lbl" Text="this is text" ForeColor="Red"></asp:Label>
</asp:Panel>
CS page:
pnl.Attributes.Add("style", "background:url(/option.PNG)");
datalist is as follows:
<asp:DataList ID="DataListComments" runat="server"
DataKeyField="Pk_Comment_Id" DataSourceID="SqlDataSourceComments" Width="100%">
<HeaderStyle BackColor="Gray" HorizontalAlign="Center" />
<HeaderTemplate>
<asp:Label ID="Label1" runat="server" BackColor="Gray"
ForeColor="White" Text="Comments" Width="100%" />
</HeaderTemplate>
<ItemTemplate>
<div class="CommentBox">
<div class="CommentImage">
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl='<%# "Profile.aspx?uid=" + Eval("fk_User_Id")%>'>
<asp:Image ID="imgUserC" runat="server"
ImageUrl='<%# Eval("Profile_Pic") %>' CssClass="scaling-image" />
</asp:HyperLink>
</div>
<div class="CommentInfo">
<div class="CommentUsername">
<asp:HyperLink ID="linkUserProfile" runat="server"
NavigateUrl='<%# "Profile.aspx?uid=" + Eval("fk_User_Id")%>'><%# Eval("Username") %></asp:HyperLink>
</div>
<div class="CommentDate">(<%# Eval("Date") %>)</div>
<div class="CommentDescription"><%# Eval("Description") %></div>
</div>
</div>
</ItemTemplate>
</asp:DataList>
Now, suppose there are 24 entries for [comments] in the database... I want to show only 3 here... And add a load more button in the footer template, on clicking this load more 5 more comments should be displayed..
If there is a possible solution to this with ajax, i wouldn't have any problem with that. I just need a working solution to this, as I am clueless on how to achieve this.
It's quite complicated when you are using runat server controls like gridview and datalist etc.
To achieve your goal:
You need to create web service
Get records from data base by using the service and JavaScript
Append the result at bottom by using JavaScript
These are things you need to do, and many other problem will start when you will work with server controls.
I want to be able to control the gap between two asp elements.
The gap got from is too much and id like to reduce it to half of that. I tried using the following modified br tah to no avail.
Please advise.
<asp:Image ID="Image5" runat="server" ImageUrl="/_Layouts/Bullet.png" /> <asp:LinkButton ID="LinkButton4" runat="server" CssClass="PreviousPollLinkButtonStyle" Onclick="renderingCurrentPoll">Current Poll</asp:LinkButton>
**<br style="line-height:2px;"/>**
<asp:Image ID="Image2" runat="server" ImageUrl="/_Layouts/Bullet.png" /> <asp:LinkButton ID="LinkButton1" runat="server" CssClass="PreviousPollLinkButtonStyle" Onclick="renderingPreviousPollResults">Previous Poll Results</asp:LinkButton>
You could put your Image and LinkButton in a DIV and use a bottom-margin:
<div style="bottom-margin:1px;padding:0;">
<asp:Image ID="Image5" runat="server" ImageUrl="/_Layouts/Bullet.png" /> <asp:LinkButton ID="LinkButton4" runat="server" CssClass="PreviousPollLinkButtonStyle" Onclick="renderingCurrentPoll">Current Poll</asp:LinkButton>
</div>
<asp:Image ID="Image2" runat="server" ImageUrl="/_Layouts/Bullet.png" /> <asp:LinkButton ID="LinkButton1" runat="server" CssClass="PreviousPollLinkButtonStyle" Onclick="renderingPreviousPollResults">Previous Poll Results</asp:LinkButton>
You may have to change the PreviousPollLinkButtonStyle CSS class.
how to display the text on ImageButton. or how to have a linkbutton on Image
I have tried this:
<asp:LinkButton ID="lbYear" runat="server" CausesValidation="false" Text="HOME">
<asp:Image ID="Image1" runat="server" ImageUrl="~/images/menu.png" Width="90px" Height="39px" />
</asp:LinkButton>
but it is showing the text above the Image..
It seems like you're actually in need of <asp:ImageButton />, which is basically an Image and LinkButton control wrapped into one:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.imagebutton.aspx
Richard.