Click here to Skip to main content
15,903,856 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to display an image in an aspx page when a RadioButton is checked. Can the image can be changed randomly.

I haven't used any DB. Is it possible?

Thanks
Posted
Updated 14-Mar-11 8:00am
v2

Instead of database use an XML file which has some id against the image url. Use Random class's Next method to create a random ID with in your ID ranges. Then from the XML find the image url for the random id. Set the image url to the image control.

Is this works?
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 14-Mar-11 16:44pm    
Reasonable answer, my 5. I added my Answer to give an important advice on UI style; what OP wants do to right now would not be acceptable; please see.
--SA
Espen Harlinn 15-Mar-11 11:50am    
Nice idea - 5!
Albin Abel 15-Mar-11 13:17pm    
Thanks Espen Harlinn
The Question by Albin is good. I only want to note on the use of RadioButton. Whatever you do with this kind of button would be the style abuse and big confusion to the user. The RadionButton is designed for a selection from the static set of options. Any randomness is inadequate.

For your purpose, you only should use some stateless control, such as regular Button.

Thank you.

—SA
 
Share this answer
 
Comments
Manfred Rudolf Bihy 14-Mar-11 17:08pm    
Of course OP didn't properly state his requirements (as usual), but giving the question some consideration I came up with a scenario that would fit in. Let's say we have three radio buttons labled "Meals", "Drinks" and "Desserts" then it could make sense to display a randomly picked image from one of the selected categories.

Given OP's current question I do agree that randomness is seldom a good choice, so have my 5!

I know that was not what OP asked for but maybe he meant something along the lines of this.

(My example is terribly construed so please forgive me). It is left to OP to come up with a better example or more solid requirements.
Sergey Alexandrovich Kryukov 14-Mar-11 17:32pm    
It's fine. Anyways. Anything above my simple considerations should be explicitly discussed, as a minimum, as only the customary behavior can be assumed, right?
--SA
Manfred Rudolf Bihy 14-Mar-11 17:56pm    
Correctamundo! :)
Albin Abel 14-Mar-11 23:14pm    
Comment on the use of radio button is agreeable. My 5
Sergey Alexandrovich Kryukov 14-Mar-11 23:23pm    
Great, thanks.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900