Rob Cooper
Rob Cooper

Reputation: 28867

ASP.NET Custom Controls - Rendering Image from a Pool of Images at Design Time

I have been working on a ImageRotator control and finished weeding out any oddities with it tonight, and it works great. However, there is one thing that is bugging me with it. It doesn't display anything at design time (I just get the image placeholder).

I have been Googling, and came across a good article from Rick Strahl (as always), and this works great for single images, where the path is explicit.

However, the ImageRotator will actually just take a path to a folder and scan that, and loop through those. Currently this doesnt work at design time because the image "pooling" doesn't work (I am thinking its because the designer doesn't give permission to the code to scan the filesystem).

So, can this be done? Would it be possible to implement a custom designer for the control and elevate permissions (or something) there?


Update Following Some Pondering While Sipping Tea (How Very British of Me!)

Would it be possible to create a Designer for the control, create an image, encode it to base64 and stick that in the code base and render it?

This way I wouldn't need to give a crap about the images in the pool because I would have my own ^_^

(Although grabbing and image from the pool would be nicer since, well, thats what the user has selected right?).

Upvotes: 0

Views: 1074

Answers (1)

Matthew M. Osborn
Matthew M. Osborn

Reputation: 4793

Hey Rick Stranl also has a post here that describes detecting design time. If its in design time just give it a fixed image from the pool. For example, alays take the first one or osmething like that.

Upvotes: 1

Related Questions