SharePoint上传循环添加label并获取上传文件名字的扩展名和文件大小(Session[demo] = new ListLabel();方法实现)...
生活随笔
收集整理的這篇文章主要介紹了
SharePoint上传循环添加label并获取上传文件名字的扩展名和文件大小(Session[demo] = new ListLabel();方法实现)...
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?
前臺
<div><asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="添加label" /><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 /><br /><br /><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<Label>();}}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 + " ";string lntext = "<a href='" + URL + "' >" + file + "</a>" + "大小" + file_KB + "上傳文件成功";List<Label> list = Session["demo"] as List<Label>;Label l = new Label();l.ID = "lbl";l.Text = lntext + "<br>";list.Add(l);Session["demo"] = list;foreach (Label item in list){Panel1.Controls.Add(item);}int max = list.Count;List<string> lavlist = new List<string>();foreach (Label item in list){lavlist.Add(item.Text);}string strValue = "";for (int i = 0; i < lavlist.Count; i++){strValue += lavlist[i];}Label2.Text = strValue;Label3.Text = lavlist.Count.ToString();}?
?
?
?
?
轉載于:https://www.cnblogs.com/914556495wxkj/p/3555159.html
總結
以上是生活随笔為你收集整理的SharePoint上传循环添加label并获取上传文件名字的扩展名和文件大小(Session[demo] = new ListLabel();方法实现)...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: cocos2dx + vs安装使用
- 下一篇: 浏览器内核信息整理