Asp:Image with Link

前端 未结 6 1178
萌比男神i
萌比男神i 2020-12-11 16:25

I would like to place an image in my application. when I click on it I want to move to another page. In general my asp:image to work as link Is that possible ??

相关标签:
6条回答
  • 2020-12-11 16:43

    sure it's possible

    <a href="Somepage.aspx"><asp:Image id="Image1" runat="server" /></a>
    

    Or if you want code-behind to handle which page you're linking to use asp:ImageButton

    <asp:ImageButton id="ImageButton1" runat="server" />
    

    and handle the click event in your code-behind

    0 讨论(0)
  • 2020-12-11 16:43

    Surround your Image with an anchor tag, like this:

    <a href="urlofmypage">
    <asp:Image............ />
    </a>
    
    0 讨论(0)
  • 2020-12-11 16:43

    asp:image has own link control. Check it.

    0 讨论(0)
  • 2020-12-11 16:44

    you can use ImageButton and on click button do a redirect to the page that you want to go to.

    0 讨论(0)
  • 2020-12-11 16:57

    You can use an ImageButton with a server side click event:

    Response.Redirect("SecondPage.aspx");
    

    Or alternatively, you could wrap a Hyperlink control around the Image control:

    <asp:hyperlink id="link" runat="server">
       <asp:image id="img" runat="server" imageurl="..." />
    </asp:hyperlink>
    

    Or just use a HTML anchor tag if you don't need the link to be dynamic:

    <a href="..">
       <asp:image id="img" runat="server" imageurl="..." />
    </a>
    
    0 讨论(0)
  • 2020-12-11 17:03

    You can add an ImageUrl to a HyperLink.

    <asp:HyperLink id="link" runat="server" imageurl="..." />
    
    0 讨论(0)
提交回复
热议问题