asp link button

I have a ASP page with code behind and it has several linkbuttons and an image control.

Depending on which one is clicked, I want to change the imageurl on the image control on the page.

I am not sure on the best way to do this other than I know I need to set the imageurl to the new value?
Who is Participating?
Carlos VillegasConnect With a Mentor Full Stack .NET DeveloperCommented:
And yes, you need to set the ImageUrl property of your Image control to display that image, for example: is a valid image url that points to a google logo.
Carlos VillegasFull Stack .NET DeveloperCommented:
Hello, here you have a full example:
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<script runat="server">
    Protected Sub LinkButton_Command(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs)
        Select Case e.CommandArgument
            Case "Image1"
                Image1.ImageUrl = ""
            Case "Image2"
                Image1.ImageUrl = ""
            Case "Image3"
                Image1.ImageUrl = ""
        End Select
    End Sub
<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
        <asp:Image ID="Image1" runat="server" />
        <br />
        <asp:LinkButton ID="LinkButton1" runat="server" OnCommand="LinkButton_Command" CommandArgument="Image1">Image A</asp:LinkButton>
        <br />
        <asp:LinkButton ID="LinkButton2" runat="server" OnCommand="LinkButton_Command" CommandArgument="Image2">Image B</asp:LinkButton>
        <br />
        <asp:LinkButton ID="LinkButton3" runat="server" OnCommand="LinkButton_Command" CommandArgument="Image3">Image C</asp:LinkButton>

Open in new window

Or download the full aspx file:
kperelmanAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.