473,326 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Add an Image to a Random Choice of a Placeholder

.NET ASP Visual Studio 2005 Visual Basic

I have a table with eight placeholders: plc1 - plc8.

The behind code:
Expand|Select|Wrap|Line Numbers
  1.         Dim p As Integer = New Integer
  2.         Dim plc As PlaceHolder = New PlaceHolder
  3.         Dim ipic As Image = New Image
  4.         ipic.ImageUrl = "Test\face_brian.jpg"
  5.         Dim plcPic(8) As String
  6.         plcPic(0) = "plc1"
  7.         plcPic(1) = "plc2"
  8.         plcPic(2) = "plc3"
  9.         plcPic(3) = "plc4"
  10.         plcPic(4) = "plc5"
  11.         plcPic(5) = "plc6"
  12.         plcPic(6) = "plc7"
  13.         plcPic(7) = "plc8"
  14.         p = (CInt(plcPic.Length - 1) * Rnd() + 1)
  15.         'Dim adrs As String = Convert.ToString(p)
  16.         plc.ID = plcPic(p)
  17.         plc.Controls.Add(ipic)
  18.  
A button starts the Subroutine.
The code runs and the debugger shows the values being populated, but the Image doesn't display! No errors post.

Why Not? Any help? It's a mystery.
Sep 17 '08 #1
2 3169
tlhintoq
3,525 Expert 2GB
I'm a C# guy, not a VB guy so I may be way off here. But they are both .NET languages so they are supposed to be somewhat transportable at least in their types.

ipic is of type Image, which in the C# world is not a Control.
In your line 17 you try to add the Image to the Controls array of the Placeholder.
So since it is not of the right type you wouldn't see anything.

In C# the image would be a property of a Control such as
Picturebox Fred = new Picturebox;
Image Wilma = new Image;
Fred.Image = Wilma;

Is there something similar in your VB world?
Placeholder.Image = ipic;
Sep 18 '08 #2
Thanks so much for your response. I was looking at this issue you pointed out. It seems there is no 'Image' Control to be added as you discerned, but an alternative is to search on an 'ID' using FindControl. While I haven't found an organized method to name the images in the source with 'IDs', this may offer a ray of hope. Thanks once again.


I'm a C# guy, not a VB guy so I may be way off here. But they are both .NET languages so they are supposed to be somewhat transportable at least in their types.

ipic is of type Image, which in the C# world is not a Control.
In your line 17 you try to add the Image to the Controls array of the Placeholder.
So since it is not of the right type you wouldn't see anything.

In C# the image would be a property of a Control such as
Picturebox Fred = new Picturebox;
Image Wilma = new Image;
Fred.Image = Wilma;

Is there something similar in your VB world?
Placeholder.Image = ipic;
Sep 18 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: matt | last post by:
I have an image randomizer that was working fine. I added five images to it today, and none of the new five are ever called. Here's the script: <!-- Begin var theImages = new Array() ...
10
by: Virus | last post by:
Ok well what I am trying to do is have 1.) the background color to change randomly with 5 different colors.(change on page load) 2,) 10 different quotes randomly fadeing in and out in random...
2
by: Brian K. Williams | last post by:
I am looking for a way to read an Image from SQL directly to a new Image or Placeholder. I have not been able to find any examples other than Response.OutputStream.Write or similar. Thanks for...
6
by: Valeri Hristov via .NET 247 | last post by:
I have a problem with a ASP.NET web site. I?m using Windows2000Server SP4, .NET Framework 1.1. The problem is that sometimes(relatively seldom) when browsing the Administration Console(see below) a...
2
by: Web Team | last post by:
Hi All, I have borrowed some code from here: http://www.codeproject.com/aspnet/aspnet_web_graphics.asp This works as expected when I use in-line code, but when I moved it to code-behind, it...
5
by: flamesrock | last post by:
Hi, It's been a while since I've played with python. My question is... whats the best way to pop a random item from a list?? -Thanks
4
by: tshad | last post by:
I am trying to set up an Image authorization where you type in the value that is in a picture to log on to our site. I found a program that is supposed to do it, but it doesn't seem to work. ...
10
by: cjparis | last post by:
Hello everyone. If anyone can give me a hand I would be gratefull Am doing a site which requires a moving element and have used DHTML to do it. Have a simple Browser detect script to sort IE...
4
by: philly_bob | last post by:
In the sample program below, I want to send a random method to a class instance. In other words, I don't know which method to send until run-time. How can I send ch, which is my random choice, to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.