I decided to reward those who grin and bear it with an iconic symbol of activity, Pacman being chased by ghosts until he goes offscreen and then returns the favor by chasing the suddenly blue ghosts back off where they came from. However, I didn't want it to do this every time. Here's the cool trick, code provided below.
////// Extends the Base.Render() method to randomly choose which image to show /// for Loading panel /// /// protected override void Render(HtmlTextWriter writer) { Image loadingImage = (Image)UpdateProgress1.FindControl("imgLoading"); if (loadingImage != null) { int pacmanFlag = new Random().Next(1, 10); loadingImage.ImageUrl = pacmanFlag == 1 ? "~/Images/indicator-pm.gif" : "~/Images/indicator-big.gif"; } base.Render(writer); }
The key is to create a Render() method which overrides the base class' method. Your asp:Image in your UpdatePanel on the page, named imgLoading in my case, gets randomly set to the specified ImageUrl.
Note: As my project is neither publicly facing nor used in the pursuit of any profit, I don't believe I'm breaking any copyright laws. If you wish to use Pacman as I have, I'm willing to share my graphic but be aware of how the copyright laws may affect your application.
No comments:
Post a Comment