How to create a link containing an image and text?

I need to create a link for an ASP.NET page with an image and text that when clicked triggers an event on the web server.

Here's what the link should look like: enter image description here

This is HTML for how the link will look if I haven’t worked with ASP.NET:

<a id='PdfLink' href='#'>
    <img src="App_Themes/.../Images/PDF.gif" alt="Click for fact sheet PDF"/>
    <span>Latest Performance</span>
</a>

The problem is that I want to be able to click this and fire the event on the server side, but I don’t know if I can do this with simple old HTML controls.

In ASP.NET, I see that there are various controls, such as ImageButton and HyperLink, but I do not see how I can have a hyperlink and ImageButton as part of the same click control.

What is the best way for me to get a link that looks like an image related to server-side functionality?

+5
5

..

<asp:LinkButton ID="LinkButton1" runat="server" 
Text="<img src='App_Themes/.../Images/PDF.gif' /> PdfLink"></asp:LinkButton>
+3

, .

<asp:LinkButton>

<asp:LinkButton id="LinkButton1" runat="server" OnClick="ButtonClick_Event" CssClass="latest-performance">Latest Performance</asp:LinkButton>

" " CssClass .

.

.latest-performance{
     display: block;
     padding-left: 20px;
     background: url(url-to-the-pdf-icon) no-repeat left center;
}

, , , , . .

+6

, ASP.NET, - :

<asp:LinkButton ID="LinkButton1" runat="Server" OnClick="ButtonClick_Event">Text</asp:LinkButton>
<asp:ImageButton ID="ImageButton1" runat="Server" ImageUrl="image.gif" OnClick="ButtonClick_Event"></asp:ImageButton>

, , , , , .

+1
<a href="../default.aspx" target="_blank">
<img src="../images/1.png" border="0" alt="Submission Form" />
    <br />
<asp:Literal ID="literalID" runat="server">Some text</asp:Literal></a>

, asp: Literal - . asp: Literal, literalID.Text , . , . - href, target img, . , .

+1

, .

<asp:HyperLink ID="hyperlink1" runat="server" NavigateUrl="Default.aspx" Target="_parent"><img src="Images/1.jpg"/>click</asp:HyperLink>
0

All Articles