↑ Grab this Headline Animator
jokiz:anyone here who is experiencing a number of blog spam comments? i am for captcha add-on, what's your stance?
i'm in the process of evalutaing several addons. consider your request granted. :)
Testing the new FTB control...
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
using System;using System.ComponentModel;using System.Web.UI;using System.Web.UI.WebControls;using System.IO;namespace KeithRull.CS.WebControls{ [DefaultProperty("Text")] [ToolboxData("<{0}:RandomImageControl runat=server></{0}:RandomImageControl>")] public class RandomImageControl : WebControl { [Bindable(true)] [Category("Appearance")] [DefaultValue("")] [Localizable(true)] public string FolderPath { get { String s = (String)ViewState["FolderPath"]; return ((s == null) ? String.Empty : s); } set { ViewState["FolderPath"] = value; } } protected override void CreateChildControls() { Image imagePlaceholder = new Image(); //create a new session variable if the variable does not exist if (ViewState["RandomImageIndex"] == null) ViewState["RandomImageIndex"] = 0; //the path of our image folder string folderPath = FolderPath; //read the directory information DirectoryInfo directoryInfo = new DirectoryInfo(folderPath); //get a list of files contained in our image directory FileInfo[] fileInfos = directoryInfo.GetFiles("*.jpg"); //get the number of files read in the directory int fileCount = fileInfos.Length; //check whether there is a file or not if (fileCount != 0) { //our random number generator Random randomGenerator = new Random((fileCount * DateTime.Now.Second) + DateTime.Now.Millisecond); //get the random number int randomImageIndex = randomGenerator.Next(fileCount); //get the stored value in our session variable int storedImageIndex = int.Parse(ViewState["RandomImageIndex"].ToString()); //compare the current and stored values to see if they are the same while (storedImageIndex == randomImageIndex) { //generate a new random number if the stored value is the same as the current one. randomImageIndex = randomGenerator.Next(fileCount); } //the full path of the image string fullName = fileInfos[randomImageIndex].FullName; //assign the random number to our session ViewState["RandomImageIndex"] = randomImageIndex; //assign the file path to our image control imagePlaceholder.ImageUrl = fullName; } this.Controls.Add(imagePlaceholder); } }}