• SharePoint上传文件显示在label 页面Session["demo"] = new List<String>();(实现)


    前台代码

     <div>
        <asp:Button ID="Button2" runat="server"   OnClick="Button2_Click" Text="添加" />
        <asp:FileUpload ID="FileUpload1" runat="server" />
    <asp:Panel ID="Panel1" runat="server" ViewStateMode="Enabled"></asp:Panel>
        <asp:HiddenField ID="HiddenField1" runat="server" />
            <br />
            个数<br />
            <asp:Label ID="Label3" runat="server"></asp:Label>
            <br />
          <p id="p1" runat="server"><%=f%></p>
            <br />
            <br />
            <br />
            <br />
            <br />
            <br />
            <br />获取的数值只要是传给label都可以正常显示<br />
            <asp:Label ID="Label2" runat="server"></asp:Label>
            </div>

    后台

      protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Session["demo"] = new List<String>();
            }
        }
        public static string f;
        protected void Button2_Click(object sender, EventArgs e)
        {
            string file_KB = FileUpload1.PostedFile.ContentLength.ToString() + "KB<br>";//获取文件大小
            string file = FileUpload1.FileName;//获取上传文件名字
    
            string URL = "http://amid01110/456/" + file + " ";
    
    
            List<string> list = Session["demo"] as List<string>;
            Session["demo"] = list;
            string lntext = "<a  href='" + URL + "'  >" + file + "</a>" + "大小" + file_KB + "上传文件成功";
    
            list.Add(lntext);
           
            foreach (string item in list)
            {
                f = item;
                //p1.InnerHtml = item;
                Response.Write(item);
                string a = item;
                string b = Session["demo"].ToString();
            }
            int max = list.Count;
    
            Label2.Text = max.ToString();
    
            Label3.Text = list.Count.ToString();
        }
  • 相关阅读:
    C# 连接 Oracle 的几种方式
    Mac电脑卸载软件后删除残余图标
    文件监视器数量达到系统限制
    Android实现伸缩弹力分布菜单效果
    XMPP协议实现原理介绍
    Android开发之日历控件实现
    OpenGL开发之旅基础知识介绍
    Android in Mono开发初体验之DataBase
    JAVA实现随机无重复数字功能
    Android实现宫格图片连续滑动效果
  • 原文地址:https://www.cnblogs.com/914556495wxkj/p/3557140.html
Copyright © 2020-2023  润新知