i want to apply onclick event on a image in the repeater.
i don't know how to do it.
anybody having any idea plz guide me.
thanks in advance

Recommended Answers

All 4 Replies

You should define image in repeater itemdatabound.
And then you can give events to image.

In repeater you can define like
HtmlImage img = e.item.FindControl("img") as HtmlImage;
Image img = e.item.FindControl("img") as Image;

thanks for your help
i have done it like this

 protected void rptthumbimg_ItemDataBound(object sender, RepeaterItemEventArgs e)
        if (e.Item.ItemType == ListItemType.Item)
            DataRowView drv = (DataRowView)e.Item.DataItem;
            dt = obj.searchimg(4, imgcatid);
            if (dt != null)
                Image imgmem = (Image)e.Item.FindControl("imgthumb");
                if (dt.Rows.Count > 0)
                    if (dt.Rows[0]["thumbnail"].ToString() == "")
                        imgmem.ImageUrl = impplaces + "memimg.png";
                        imgmem.ImageUrl = impplaces + dt.Rows[0]["thumbnail"].ToString();

i want to implement onclick event on this image and i dont know hoe to do it.

imgmem.Attributes.Add("onclick", "eventname");

thank you very much for all ur help.it was really helpfull to me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.