Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have used ListView control called ListView_image in my ASP.net website, the listview just displays the a image list, I want to click each one and then redirect to one new page, but I do not know how to do with it. then I try to use ItemCommand. But I found this function can not called when I click the image.
the following is just a simple test. Note that, I just want to test when this function will be fired.
any one can give me a hint? Note that, the image list has been displayed sucessfully from a data sourece.

C#
protected void ListView_image_ItemCommand(object sender, ListViewCommandEventArgs e)
{
    MessageBox.Show(e.Item.ToString());
}
Posted
Updated 22-Jun-12 6:14am
v2
Comments
ZurdoDev 22-Jun-12 11:48am    
First off, you can't do MessageBox.Show in ASP.Net. ASP.Net code runs on the server, generates html, and then sends the html to the client.
Seraph_summer 22-Jun-12 12:25pm    
you are right. but here, I just want to test to check whether this function is called or not.
cpsglauco 22-Jun-12 12:42pm    
can you post aspx code too?

1 solution

Hi,
You just try this and check whether your grid is firing event or not.
C#
protected void ListView_image_ItemCommand(object sender, ListViewCommandEventArgs e)
{
        ScriptManager.RegisterClientScriptBlock(base.Page, this.GetType(), "Myscript", "alert('Event fired..');", true); 
}


All the best.
--AK
 
Share this answer
 
Comments
Seraph_summer 23-Jun-12 11:54am    
thanks, but it is not fired.
I do not really know what happens. confused.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900