惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
人人都是产品经理
人人都是产品经理
H
Hacker News: Front Page
Stack Overflow Blog
Stack Overflow Blog
B
Blog
I
InfoQ
GbyAI
GbyAI
T
The Blog of Author Tim Ferriss
F
Fortinet All Blogs
Y
Y Combinator Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
月光博客
月光博客
Hugging Face - Blog
Hugging Face - Blog
爱范儿
爱范儿
F
Full Disclosure
Hacker News - Newest:
Hacker News - Newest: "LLM"
Recent Announcements
Recent Announcements
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Jina AI
Jina AI
T
Tailwind CSS Blog
S
Secure Thoughts
P
Privacy International News Feed
美团技术团队
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
L
LINUX DO - 最新话题
H
Hackread – Cybersecurity News, Data Breaches, AI and More
C
Cybersecurity and Infrastructure Security Agency CISA
Last Week in AI
Last Week in AI
W
WeLiveSecurity
Google Online Security Blog
Google Online Security Blog
P
Privacy & Cybersecurity Law Blog
D
DataBreaches.Net
Engineering at Meta
Engineering at Meta
Know Your Adversary
Know Your Adversary
P
Palo Alto Networks Blog
I
Intezer
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Project Zero
Project Zero
V2EX - 技术
V2EX - 技术
H
Heimdal Security Blog
博客园 - Franky
阮一峰的网络日志
阮一峰的网络日志
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Troy Hunt's Blog
V
Vulnerabilities – Threatpost
H
Help Net Security
Martin Fowler
Martin Fowler
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
G
GRAHAM CLULEY
博客园 - 【当耐特】

博客园 - kenly33

ORM及代码生成器和插件C#源码(最新版Kenly.DBFramework4.5.8.5) 處理RadioButtonList客戶端事件 - kenly33 - 博客园 对象关系映射架构(DBFramework)及代码生成器和插件(源码) 使對象支持自定義比較 統計分數 讀寫XML文檔 - kenly33 - 博客园 Visual Studio Team System简介 过滤某些字段重复的记录 GridViewNavigator Gridview梆定 兩個輸入框只允許一個輸入 Gridview中梆定得RadioButton Javascript 隱藏或顯示某區域 ASP.NET 2.0中合并 GridView 的表头单元格 VS2005 RESOURCE MANAGEMENT 鲸鱼哲学 Javascript彈出對話框 FxCop Rules Atlas使用演练
MultiFileUploador
kenly33 · 2007-05-11 · via 博客园 - kenly33

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="MultiFileUploador.ascx.cs" Inherits="Controls_MultiFileUploador" %>

<script language=javascript type="text/javascript">

var _controlPrefix="MultiFileUploador1_";
var _fileCount=1;
var _insertedScript="";

function AddFile()
{
    _fileCount=_fileCount+1;
    var newDiv=CreateDiv(_fileCount);
    _insertedScript=_insertedScript+newDiv;
    document.getElementById('divNewFile').insertAdjacentHTML("beforeEnd",newDiv);
}

function DeleteFile(fileIndex)
{
    document.getElementById("div"+fileIndex).style.display="none";
    document.getElementById("file"+fileIndex).value=null;
    _insertedScript=_insertedScript.replace(CreateDiv(fileIndex),"");
//    document.getElementById('divNewFile').innerHTML=document.getElementById('divNewFile').innerHTML.replace(CreateDiv(fileIndex),"");
}

//function ReloadInsertedScript()
//{
//   document.getElementById('divNewFile').insertAdjacentHTML("beforeEnd",_insertedScript)
//}

function CreateDeleteButton(fileIndex)
{
   var newDeleteId="btnDelete"+fileIndex;
   var deleteButton='<input id='+newDeleteId+' type="button" value="delete"  size="42"  language="javascript" onclick="return DeleteFile('+fileIndex+')" style="height: 20px"/>';
   return deleteButton;
}

function CreateFileControl(fileIndex)
{
   var newFileId="file"+fileIndex;
   var fileControl = '<INPUT id='+newFileId+' type="file" size="42" NAME="File">';
   return fileControl;
}

function CreateDiv(fileIndex)
{
    var newDivId="div"+fileIndex;
    var newDiv='<div id='+newDivId+'>'+CreateFileControl(fileIndex)+CreateDeleteButton(fileIndex)+'</div>';
    return newDiv;
}

           
function btnAddnew_onclick()
{
    AddFile();
}

</script>

<div style="padding-left:4px">
 
    <asp:FileUpload ID="FileUpload1" runat="server" Width="300px" /><input id="btnAddnew" type="button" value="more.."  size="42"  language="javascript" onclick="return btnAddnew_onclick()" style="height: 20px"/>

    <div id="divNewFile" >
    </div>

</div>

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Controls_MultiFileUploador : System.Web.UI.UserControl
{

    private string _insertedScript = "";

    public HttpFileCollection AllFiles
    {
        get
        {
            return HttpContext.Current.Request.Files;
        }
    }

    public List<HttpPostedFile> SelectedFiles
    {
        get
        {
            return FilterNullFile(HttpContext.Current.Request.Files);
        }
    }

    public string InsertedScript
    {
        get
        {
            return _insertedScript;
        }
        set
        {
            _insertedScript = value;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.Unload += new EventHandler(Controls_MultiFileUploador_Unload);
            this.Init += new EventHandler(Controls_MultiFileUploador_Init);
        }
    }

    void Controls_MultiFileUploador_Init(object sender, EventArgs e)
    {
       
    }

    void Controls_MultiFileUploador_Unload(object sender, EventArgs e)
    {
       
    }

    public List<HttpPostedFile> FilterNullFile(HttpFileCollection SelectedFiles)
    {
        List<HttpPostedFile> newHttpFiles=new List<HttpPostedFile>();

        for (int i = 0; i < SelectedFiles.Count; i++)
        {
            if (!string.IsNullOrEmpty(SelectedFiles[i].FileName) && SelectedFiles[i].ContentLength > 0)
            {
                newHttpFiles.Add(SelectedFiles[i]);
            }
        }

        return newHttpFiles;

    }
   
}