This is a migrated thread and some comments may be shown as answers.

open another window when clicking an image

1 Answer 91 Views
Rotator
This is a migrated thread and some comments may be shown as answers.
mww
Top achievements
Rank 1
mww asked on 04 Aug 2010, 08:48 PM
I want to place a RADRotator in a page, with vertical orientation.  I need to display a series of images that are stored in a database.  When a  user clicks one of the images in the rotator, I want to open up another window, the window will show some details relating to the picture form a database.  So my question is, how can have a 'onlick' event associated with each image in the rotator that would execute some code like this

Response.Redirect("thepage.aspx?id=" +  get an id from the image here)

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 05 Aug 2010, 08:57 AM
Hello,

Here is one approach that you can try for achieving the requirement.

Attach 'ItemDataBound' to the Rotator control and access the image controls to add "onclick" attribute to it. Also pass the ImageName/ImageId to the event handler so that you can access corresponding image in the new window page.

A sample code is shown below:
protected void thumbRotator_ItemDataBound(object sender, RadRotatorEventArgs e)
{
    if (e.Item is RadRotatorItem)
    {
        RadRotatorItem dataItem = e.Item as RadRotatorItem;         
        Image thumbImage = (Image)dataItem.FindControl("thumbImage"); // Access the image using ID
        thumbImage.ImageUrl = "Handler.ashx?Size=S&PhotoID=" + imageId;
        thumbImage.Attributes["onclick"] = string.Format("return PopupImage('{0}');", imageId);
    }
 
}


Now in the client side, open the window and pass the parameter as url parameter.
function PopupImage(ImageId) {
    var oWnd = window.radopen("ImagePopUp.aspx?ImageId=" + ImageId);
    oWnd.SetSize(530, 600);
    oWnd.Center();
}



-Shinu
Tags
Rotator
Asked by
mww
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or