0

I am working in asp.net and mysql. Will shows the details of rooms in page with images that getting for mysql database,. In the Main Image will change when i click the small size image buttons.

I want to replace the Image1 ImageUrl "~/GetRoomImage.aspx?id=1" to "~/GetRoomImage.aspx?id=2" or "~/GetRoomImage.aspx?id=3" like this,. when clicking the regading imagebutton.

Please help me to get this in Jquery.

enter image description here

My Code,..

<asp:Image ID="Image1" runat="server" ImageUrl="~/GetRoomImage.aspx?id=1" Height="178" Width="178"></asp:Image>   <br /><br />
                      &nbsp;
                     <asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/GetRoomImage.aspx?id=2" Height="30" Width="37" /> &nbsp;
                     <asp:ImageButton ID="ImageButton3" runat="server" ImageUrl="~/GetRoomImage.aspx?id=3" Height="30" Width="37" />&nbsp;
                     <asp:ImageButton ID="ImageButton4" runat="server" ImageUrl="~/GetRoomImage.aspx?id=4" Height="30" Width="37" />&nbsp;
                     <asp:ImageButton ID="ImageButton5" runat="server" ImageUrl="~/GetRoomImage.aspx?id=5" Height="30" Width="37" />
0

2 Answers 2

1

you can bind an event for every small image click on page load and assigning the src from the small image to larger image.

$(document).ready(function(){
      $('input[type=image]').click(function(){

          var newImg = $(this).attr("src");
           $("#Image1").attr("src",newImg)
       });
}); 
Sign up to request clarification or add additional context in comments.

2 Comments

I am not using html image, how to change the imageurl in asp. pls note my req. thanks
ASP.NET server controls will be rendered as html controls in browser, so <asp:ImageButton> will be rendered as input[type=image]. See my updated answer
0

Try this

$(document).ready(function(){
  $("[value ^= 'ImageButton']").click(function(){
      var newImg = $(this).attr("src");
       $("#Image1").attr("src",newImg)
   });
}); 

1 Comment

can i change the src to ImageUrl. bzs i am using asp image

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.