您的位置:首页 > 其它

后台处理图片路径显示到前台DIV中

2009-09-27 17:34 543 查看
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;
//}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐