how to display the text on ImageButton - asp.net

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.

Related

hyper link button Target __blank not working while click image within repeater control

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>

asp.net label over asp.net image

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)");

imagefield clickable in a gridview

i have this imagefield in a gridview
<asp:ImageField HeaderText="Image" DataImageUrlField="Image_Path" ControlStyle-Width="50" ControlStyle-Height="50"/>
the image_path is a column name from the database that retuns the image link
i need to make this field clickable so once i click on it i need to popup a form just like this field:
<asp:TemplateField HeaderText="View">
<ItemTemplate>
<asp:LinkButton ID="LinkButton3" CommandName="Select" onClick="popup_click" class="table-actions-button ic-table-edit" runat="server"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
i tried to put an image button instead of an image field but i'm always getting submit query instead of the image...
<asp:TemplateField HeaderText="Image">
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" DataImageUrlFormatString="Image_Path" ControlStyle-Width="50" ControlStyle-Height="50"/>
</ItemTemplate>
does anyone know how can i fix this?

background-image eval

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>

Hyperlink control (inside TemplateField tags) is not acting like an anchor tag?

I have this murkup somewhere in my gridview. The gridview is showing the data for that column, but it's not showing up like an anchor tag, i.e. no underlining and not possible to click it (Just like plain-tex).
<asp:TemplateField HeaderText="Status" Visible="True"> <ItemTemplate>
<asp:HyperLink ID="statusHpLink" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "Status") %>' /> </ItemTemplate>
<ItemStyle CssClass="itemstyle" />
</asp:TemplateField>
Thanks for helping
YOu need to set the NavigateUrl attribute in your markup.
<asp:HyperLink runat="server" ID="link" Text="Click Me"
NavigateUrl="http://stackoverflow.com"/>

Resources