我已经动态创建了一个Div,其中所有图像加载后我加载了图像我创建了一个新的Div并希望在图像后显示新的Div [英] I Have Dynamically Created A Div In Which I Loaded Images After All The Images Loaded I Created A New Div And Want To Display New Div After The Images
本文介绍了我已经动态创建了一个Div,其中所有图像加载后我加载了图像我创建了一个新的Div并希望在图像后显示新的Div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
protected void BindMainGallery()
{
try
{
using (EConnectContext context = new EConnectContext())
{
mltvGallery.ActiveViewIndex = 0;
var gallery = from p in context.PhotoGallery
where p.IsVisible == true && p.ActiveFrom <= DateTime.Now && p.ActiveTill >= DateTime.Now
select new
{
GalleryName = p.Name,
ID = p.ID,
//Title = c.Title,
//Description = c.Description,
//ImgPath = c.ImageFilePath,
//ImgContent = c.ImageFileContent,
//ImgName = c.ImageFileName
};
LiteralControl li = new LiteralControl();
if (gallery.Count() > 0)
{
foreach (var g in gallery.ToList())
{
var photoGallery = context.Gallery.Where(a => a.GalleryID == g.ID && a.IsHome == true && a.IsVisible == true).ToList().FirstOrDefault();
li = new LiteralControl();
if (photoGallery != null)
{
//li.Text = "<a href="#">"+g.GalleryName+"</a>";
if (File.Exists(Server.MapPath("~/" + photoGallery.ImageFilePath)))
{
li.Text = "<div class="\"fram\""></div><div class="txtGallery">" + g.GalleryName + "</div>";
}
else
{
string fileID = Guid.NewGuid().ToString();
FileStream fsImg = new FileStream(Server.MapPath("~/Docs/" + fileID + photoGallery.ImageFileName), FileMode.Create, FileAccess.Write);
string filePath = "Docs/" + fileID + photoGallery.ImageFileName;
Byte[] imgBytes = photoGallery.ImageFileContent;
fsImg.Write(imgBytes, 0, imgBytes.Length);
fsImg.Close();
li.Text = "<div class="\"fram\""></div><div class="txtGallery">" + g.GalleryName + "</div>";
}
}
else
{
li.Text = "<div class="\"fram\""></div><div class="txtGallery">" + g.GalleryName + "</div>";
}
divMain.Controls.Add(li);
}
}
li = new LiteralControl();
li.Text = "<div style="border-style:dashed;padding:0 10px 0 10px;removed:absolute;margin-removed20px;"><a style="text-decoration:none;" href="\"#\"" önclick="showModalPopUp();"><div>+</div></a></div>";
divMain.Controls.Add(li);
};
}
catch (Exception ex)
{
ShowAlert(ex.Message);
}
}
Aspx代码
Aspx code
<div id="divMain" runat="server" style="min-height:700px;" class="main">
Css Class=.main
{
float: left;
height: auto;
width: auto;
}
推荐答案
这篇关于我已经动态创建了一个Div,其中所有图像加载后我加载了图像我创建了一个新的Div并希望在图像后显示新的Div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文