Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 31st, 2006, 05:09 AM
Authorized User
 
Join Date: Nov 2005
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default Cycling through ImageButtons

Hi all,

I have 5 ImageButton's that i would like to cycle through and set the ImageUrl property. There labelled ImageButton1,ImageButton2, etc.
How do i reference these as in "ImageButton" + i to set the properties.

Any Help greatly appreciated.
 
Old September 1st, 2006, 08:20 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Create an Array.

ImageButton ib[];

ib = new ImageButton[]{this.ImageButton1, this.ImageButton2, this.ImageButton3, this.ImageButton4, this.ImageButton5}

Now you could loop through this array however you have to, for example:

foreach(ImageButton btn in ib){
   btn.ImageUrl = "./somepage.aspx"
}

hth

"The one language all programmers understand is profanity."
 
Old September 3rd, 2006, 04:40 AM
Authorized User
 
Join Date: Nov 2005
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks very much,

I knew it was something simple, just couldn't put my hand on it.

Cheers





Similar Threads
Thread Thread Starter Forum Replies Last Post
CodeBehind: Multiple ImageButtons, One Click Event bsausser ASP.NET 1.0 and 1.1 Basics 11 October 18th, 2006 10:50 PM
Cycling through all text boxes sjf905 C# 2 September 21st, 2006 12:43 AM
SetTimeout Image Cycling in Circle sasidhar79 Javascript 7 July 3rd, 2004 12:30 AM
Cycling through each record in ASP with MS Access imercha ASP.NET 1.0 and 1.1 Basics 1 March 29th, 2004 02:51 AM
Multiple image cycling foxntd Javascript How-To 1 June 6th, 2003 02:47 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.