PageAdmin网站内容管理系统(CMS)交流论坛

注册

 

QQ登录

只需一步,快速开始

发新话题 回复该主题

做了个下载专区,怎么在下载列表里读取编辑器里面附件的大小 [复制链接]

1#
做了个下载专区,怎么在下载列表里读取编辑器里面附件的大小?

分享 转发
TOP
2#

RE:做了个下载专区,怎么在下载列表里读取编辑器里面附件的大小

回复 1楼hmgy的帖子

能回复下吗?
TOP
3#

方法1:在列表页模板中通过c#的FileInfo对象来读取大小,参考:http://c.biancheng.net/view/2919.html
方法2:通过系统自带的方法,参考:http://www.pageadmin.net/help/60.cshtml
TOP
4#

不能在此范围内声明名为“item”的局部变量

回复 3楼xiyou的帖子

读取大小 提示 NewsliList.cshtml(73): error CS0136: 不能在此范围内声明名为“item”的局部变量,因为这样会使“item”具有不同的含义,而它已在“父级或当前”范围中表示其他内容了!
  1. @{
  2.     string templateDirectory = ViewBag.TemplateDirectory;
  3.     int columnId = Html.CurrentColumnId();//当前栏目id
  4.     PageInfo pageInfo = new PageInfo()
  5.     {
  6.         PageSize = 10,//每页显示12条数据
  7.         CurrentPage = (int)ViewBag.CurrentPage //当前页码,系统预设
  8.     };
  9.     var dataList = Html.InfoDataList(new { ColumnId = columnId }, null, null, pageInfo);
  10.     var columnContentData = Html.ColumnContentData();
  11.     string zdytitle = columnContentData.Zlmlmmc;
  12. }

  13. @Html.Partial("xBannerPartial")

  14. <div class="container">
  15.     @Html.Partial("BreadcrumbPartial")
  16. </div>
  17. <div class="container">
  18. <div class="row margin-top-20">
  19.     <div class="web_navs1 margin-top-10">
  20.         @Html.Partial("subNavPartial")
  21.     </div>
  22.     <div class="margin-top-10">
  23.         <div class="zlm_news_mx web_wzwc_com">
  24.             @foreach (var item in dataList)
  25.             {
  26.                 string title = item.Title;
  27.                 if (title.Length > 30)
  28.                 {
  29.                     title = title.Substring(0, 30) + "...";
  30.                 }
  31.                 string introduction = item.Introduction;
  32.                 if (introduction.Length > 260)
  33.                 {
  34.                     introduction = introduction.Substring(0, 260) + "...";
  35.                 }
  36.                 string date = item.Thedate.ToString("MM/dd");
  37.                 string dates = item.Thedate.ToString("yyyy");
  38.                 string url = Html.InfoDataUrl((int)item.ColumnId, (int)item.Id);
  39.                 string thumbnail = item.Thumbnail;
  40.                 {

  41.                     <div class="news-item clearfix">
  42.                         <a href="@url" target="_self" class="clearfix">
  43.                             <div class="news-item-box">
  44.                                 <div class="news-con-box">
  45.                                     <div class="news-time">
  46.                                         <time>@item.Thedate.ToString("yy-MM-dd")</time>

  47.                                         <div class="news-icon">
  48.                                             <span></span>
  49.                                         </div>
  50.                                     </div>
  51.                                     <div class="news-con">
  52.                                         <p class="news-title">
  53.                                             @title
  54.                                         </p>
  55.                                         <p class="news-desc layout-107-news-desc" style="height: 120px; word-break: break-all; overflow: hidden; text-overflow: ellipsis; -webkit-line-clamp: 2; display: -webkit-box; -moz-box-orient: vertical;">@introduction</p>
  56.                                         
  57.                                     </div>
  58.                                 </div>
  59.                                 <div class="news-img">
  60.                                     <img src="@thumbnail" class="t-img">
  61.                                     <div class="dummy"></div>
  62.                                 </div>
  63.                             </div>
  64.                         </a>
  65.                         <div>
  66.         <!--读取文件大小-->

  67.                                         <ul>
  68.            @foreach (var item in Html.AttachmentDataList(new { ParentId=1, ParentTable = "news", ParentField = "content" }))
  69.     {
  70.     <li>
  71.         <img src="@item.Path" alt="获取文件路径" />
  72.         <img src="@item.Thumbnail" alt="图片缩列图路径,附件组此字段为空" />
  73.         <span>文件大小:@item.Size kb</span>
  74.     </li>
  75. }
  76. </ul>
  77. <!--读取文件-->
  78.         </div>
  79.                     </div>
  80.                     

  81.                 }
  82.             }
  83.             
  84.         </div>
  85.         
  86.             @Html.Partial("PagebreakPartial", pageInfo)
  87.     </div>
  88. </div>
  89. </div>
复制代码
TOP
发新话题 回复该主题