open another window when clicking an image

2 posts, 0 answers
  1. mww
    mww avatar
    257 posts
    Member since:
    Sep 2012

    Posted 04 Aug 2010 Link to this post

    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)
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 05 Aug 2010 Link to this post


    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);

  3. DevCraft R3 2016 release webinar banner
Back to Top