Reputation: 83
I have 8 or more Image controls each inside HyperLink and PlaceHolder I need to change parameters of each. It's for a Sitefinity gallery control. Right now I do this times 8:
if (String.IsNullOrEmpty(Image_1_File_Name) == true) {
Image1_ph.Visible = false;
}
else {
productImageLink1.NavigateUrl = Folder_URL + Image_1_File_Name + "_l.jpg";
productImageLink1.Attributes.Add("rel", "zoom-id:"+ zoom.ClientID +";zoom-fade: true");
productImageLink1.Attributes.Add("rev", Folder_URL + Image_1_File_Name + "_m.jpg");
productImage1.ImageUrl = Folder_URL + Image_1_File_Name + "_tn.jpg";
productImage1.AlternateText = Image_1_Alt_Tag;
}
I just copy&paste it and replace number. But I want to do this in a loop I just can't find a way to reference each set of controls.
How can this be accomplished?
Upvotes: 0
Views: 1474
Reputation: 981
You can use recursion to loop through various controls within panels. Here's an example.
Upvotes: 4
Reputation: 1271
Here is an approach that may work for you:
This will eliminate the need for the loop.
A google search will probably give you all kinds of help/tutorial on how to create inherited server controls.
Upvotes: 0