a.前台:<div id="divPhoto" runat="server">
                        </div>
b.后台:
 protected void Page_Load(object sender, EventArgs e)
        {
            StringBuilder sbInnerHtml = new StringBuilder();
            sbInnerHtml.Append("<MARQUEE direction='left' width='508' height='86' scrollAmount='2'>"); //class='move'
            string photoPath = AppDomain.CurrentDomain.BaseDirectory + "Images\\Gory";

            DirectoryInfo dir = new DirectoryInfo(photoPath);
            int i = 0;
            foreach (FileInfo f in dir.GetFiles("*.jpg"))
            {
                String name = f.Name;
                long size = f.Length;
                DateTime creationTime = f.CreationTime;
                sbInnerHtml.Append("<a href=\"..\\Images\\Gory\\" + name + "\" rel=\"lightbox[roadtrip]\" >");
                sbInnerHtml.Append("<img id=\"" + i.ToString() + "\" src=\"..\\Images\\Gory\\" + name + "\" width=\"120px\"; height=\"168px\" style=\"border: 1px #dcdcdc solid; width: 120px; text-align: center; float: left;padding-top: 5px; height: 85px; margin: 10px;\"/>");
                sbInnerHtml.Append("</a>");
                i++;
                //if ((i % 5) == 0)
                //    sbInnerHtml.Append("<br/>");
            }
            sbInnerHtml.Append("</marquee>");
            divPhoto.InnerHtml = sbInnerHtml.ToString();
        }
        public string Get(object obj)
        {
            string str = obj.ToString();
            if (str.Length > 10)
            {
                return str = str.Substring(0, 10).ToString() + "....";
            }
            return str;
        }

        //public void AuthenticationUsers(string username)
        //{
        //    FormsAuthenticationTicket tichet = new FormsAuthenticationTicket(1, username, DateTime.Now, DateTime.Now.AddHours(24), true, "");
        //    string hashTicket = FormsAuthentication.Encrypt(tichet);
        //    HttpCookie userCookie = new HttpCookie(FormsAuthentication.FormsCookieName);
        //    userCookie.Value = hashTicket;
        //    userCookie.Expires = tichet.Expiration;
        //    userCookie.Domain = FormsAuthentication.CookieDomain;
        //    HttpContext.Current.Response.Cookies.Add(userCookie);
        //}

        //public static string EncryptPassword(string passwordString)
        //{
        //    string password = string.Empty;
        //    if (!string.IsNullOrEmpty(passwordString))
        //    {
        //        password = FormsAuthentication.HashPasswordForStoringInConfigFile(passwordString, "SHA1");
        //    }
        //    return password;
        //}

Posted on 2009-09-27 17:34  邬江-远波  阅读(578)  评论(0编辑  收藏  举报