Save id of an image clicked on (Web Forms)


Excuse me, can anyone help me with the following? Language: ASP Web Forms, c # not PHP.  How could you save the id of an image when you click it? ...

I want to make a page for a library, when I click on the image of the book, redirect me to another page where I can show the information of the book, I already have the beginning that shows the books with their respective id, I want save the data of the book clicked to show them later in the page of the information of the book, I do not know how to send the information of the image clicked to the other page. Please help: c

asked by Alan Hernandez Blacklist125 09.09.2016 в 12:21

2 answers


It would be best if you put the images of the books inside links and each of them redirected to the page of the book already with the ID in the url:

<a href="libro.aspx?ID=3"><img src='imagenlibro.jpg'/></a>

Then with Request.QueryString["ID"] you capture the ID from the book.aspx page.

answered by 09.09.2016 / 12:31

You can perform a redirect using jQuery easily. As explained in this question .

Defines an HTML element of any kind with a onClick defined such that:

<asp:Button ID="Button1" runat="server" Text="Texto" OnClick="Redirige"></asp:Button>

And we define the function Redirige :

<script type="text/javascript" lang="javascript">
   function Redirige() {
       window.location.href = "";

From here you already have it.

answered by 09.09.2016 в 12:30