后台处理图片路径显示到前台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;
//}
</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;
//}
相关文章推荐
- Java +spring MVC 后台图片流在前台页面显示
- struts的日期处理(后台Date或者Timestamp)前台显示
- 后台配置前台动态显示图片——善良公社
- yii2后台上传图片,前台也能显示 的方法
- dede验证码不显示,dede图集后台上传图片报错 提示红色FILEID错误的处理办法
- 关于后台处理上传图片和显示图片的简单介绍(亲测)
- imgAreaSelect做前台图片截取+java后台处理
- dedecms中PC和移动端后台后,图片路径处理
- MVC中根据后台绝对路径读取图片并显示在IMG中
- 前台获取后台返回的图片并显示
- MVC中根据后台绝对路径读取图片并显示在IMG中
- 前台给后台传图片处理方法
- asp.net后台InputStream存储图片,前台js接收解析存放路径地址
- loner_li JQuery插件 实现相册光箱特效(后台数据库调图片和前台直接显示)
- django 后台上传图片在前台显示urls,model,html,view
- 《项目经验》--后台一般处理程序向前台JS文件传递JSON,JS解析JSON,将数据显示在界面--显示在DropDownList 或 显示在动态创建的table中
- 后台传过来的JSON数据里的date传到前台的时候显示的是【Object object】 处理方法
- Android上传图片到服务器并显示(后台用Java处理)
- web:后台生成图片供前台显示
- 《项目经验》--后台一般处理程序向前台JS文件传递JSON,JS解析JSON,将数据显示在界面--显示在DropDownList 或 显示在动态创建的table中