G
Guest
I have a button on a form that creates multiple ImageButtons; I want each
ImageButton's click event to then redirect to another URL. From doing some
research, I understand this has to do with ImageButtons (and their handlers)
not being re-assigned on postback, but how do I accomplish the above?
....
ImageButton ib = new ImageButton();
ib.Width = 100;
ib.Height = 80;
ib.ImageUrl = @"http://mysite.com/images/image1.jpg";
ib.ID = "ib1";
ib.Click += new System.Web.UI.ImageClickEventHandler(this.ib_Click);
ib.Attributes["runat"]="server";
ib.EnableViewState = true;
PImages.Controls.Add(ib);
....
private void ib_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
Response.Redirect(@"http://www.microsoft.com");
Response.End();
}
ImageButton's click event to then redirect to another URL. From doing some
research, I understand this has to do with ImageButtons (and their handlers)
not being re-assigned on postback, but how do I accomplish the above?
....
ImageButton ib = new ImageButton();
ib.Width = 100;
ib.Height = 80;
ib.ImageUrl = @"http://mysite.com/images/image1.jpg";
ib.ID = "ib1";
ib.Click += new System.Web.UI.ImageClickEventHandler(this.ib_Click);
ib.Attributes["runat"]="server";
ib.EnableViewState = true;
PImages.Controls.Add(ib);
....
private void ib_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
Response.Redirect(@"http://www.microsoft.com");
Response.End();
}