折腾大半夜终于搞定下载页面获取文件的方法,先上张图欣赏下效果,还有句话告诉老大,我是个搞前端的,现在活生生被逼得去研究后端,哎!!
然后上模版页面代码
- @{
- string templateDirectory = ViewBag.TemplateDirectory;
- int columnId = Html.CurrentColumnId();//当前栏目id
- PageInfo pageInfo = new PageInfo()
- {
- PageSize = 10,//每页显示12条数据
- CurrentPage = (int)ViewBag.CurrentPage //当前页码,系统预设
- };
- var dataList = Html.InfoDataList(new { ColumnId = columnId }, null, null, pageInfo);
- var columnContentData = Html.ColumnContentData();
- string zdytitle = columnContentData.Zlmlmmc;
- }
- @Html.Partial("xBannerPartial")
- <div class="container">
- @Html.Partial("BreadcrumbPartial")
- </div>
- <div class="container">
- <div align="center" class="xiazaizhuanqu"><div class="kuang"><span class="s1">下载中心</span></div></div>
- <div class="row margin-top-20">
- <div class="margin-top-10">
- <div class="zlm_news_mx web_wzwc_com">
- @foreach (var item in dataList)
- {
- string title = item.Title;
- if (title.Length > 30)
- {
- title = title.Substring(0, 30) + "...";
- }
- string introduction = item.Introduction;
- if (introduction.Length > 260)
- {
- introduction = introduction.Substring(0, 260) + "...";
- }
- string date = item.Thedate.ToString("MM/dd");
- string dates = item.Thedate.ToString("yyyy");
- string url = Html.InfoDataUrl((int)item.ColumnId, (int)item.Id);
- string thumbnail = item.Thumbnail;
- {
- <div class="download">
-
- <div class="download_lb">
- <div class="lbtite">
- <p class="news-title">
- @title <span> 【@introduction】</span>
- </p>
- </div>
- @foreach (var itemq in Html.AttachmentDataList(new { ParentId=(int)item.Id , ParentTable = "news",
- ParentField = "content" })) //这里获取附件表里上传的文件大小,我是用的新闻信息表改的,所以用的news,我有时候需要上传多个附件,所以没有另外添加附件的字段,用的是编辑器里面附件上传的。
- {
- <div class="lbsize">
- <span>@((itemq.Size/1024).ToString("F3")) MB</span><!--这里的Size获取的是kb,以为上传到编辑器里面的附近默认是kb,需要/1024转换成MB,如果你需要转行成GB 就需要写成(itemq.Size/1024/1024),后面的F3代表只取小数点后面3位并且四舍五入,如果你需要2位,就写F2,4位F4 以此类推-->
- </div>
- <div class="lbdown"><a href="@itemq.Path" target="_self" class="clearfix" title="@introduction">下载</a></div>
- }
- </div>
-
- <div>
- </div>
- </div>
-
- }
- }
-
- </div>
-
- @Html.Partial("PagebreakPartial", pageInfo)
- </div>
- </div>
- </div>
复制代码