Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > C# (.NET) > ASP.NET Upload File > (C#) ASP.NET Upload & Create Control - FindControl



Clound SSD Virtual Server

(C#) ASP.NET Upload & Create Control - FindControl

(C#) ASP.NET Upload & Create Control - FindControl เขียน ASP.NET สร้าง Control FileUpload ขึ้นมาใหม่ และทำการอัพโหลดตามจำนวน Control ที่ได้ทำการสร้างขึ้นมา

Language Code : VB.NET || C#

Framework : 2,3,4

AspNetCreateFileUpload.aspx

<%@ Page Language="C#" Debug="true" %>
<script runat="server">

	void ddlNum_Changed(Object sende, System.EventArgs e)
	{
        int i;
        FileUpload fileUpload;
		Label lblBr;
        for( i = 1; i <= Convert.ToInt32(this.ddlNum.SelectedItem.Value);i++)
		{
            fileUpload = new FileUpload();
            fileUpload.ID = "fiUpload" + i;

			lblBr = new Label();
			lblBr.Text = "<br>";
			this.pnlCtrl.Controls.Add(fileUpload);
			this.pnlCtrl.Controls.Add(lblBr);
        }

		if(Convert.ToInt32(this.ddlNum.SelectedItem.Value) > 0)
		{
			this.btnUpload.Visible = true;
		}
		else
		{
			this.btnUpload.Visible = false;
		}

		this.form1.Enctype = "multipart/form-data";
	}

    void btnUpload_OnClick(Object sender, EventArgs e)
	{
			int i;
			HttpFileCollection myUpoad = Request.Files;
			HttpPostedFile myFiles;
			for( i = 0; i<= Convert.ToInt32(this.ddlNum.SelectedItem.Value)-1;i++)
			{
				myFiles = (HttpPostedFile)myUpoad[i];
				if(myUpoad.Keys[i].ToString() == ("fiUpload" + (i + 1)).ToString())  //*** Check Control ***//
				{
					if(myFiles.FileName.ToString() != "")
					{
						String strFileName = System.IO.Path.GetFileName(myFiles.FileName);
						myFiles.SaveAs(Server.MapPath("Myfiles/" + strFileName));
						this.lblText.Text = this.lblText.Text + strFileName + " Uploaded.<br>";
					}
				}
			}

			this.lblText.Visible = true;
			this.btnUpload.Visible = false;
			this.ddlNum.Visible = false;
    }

</script>
<html>
<head>
<title>ThaiCreate.Com ASP.NET - Upload files</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:DropDownList id="ddlNum" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlNum_Changed">
        <asp:ListItem Text="0" Value="0"></asp:ListItem>
		<asp:ListItem Text="1" Value="1"></asp:ListItem>
        <asp:ListItem Text="2" Value="2"></asp:ListItem>
        <asp:ListItem Text="3" Value="3"></asp:ListItem>
        <asp:ListItem Text="4" Value="4"></asp:ListItem>
        <asp:ListItem Text="5" Value="5"></asp:ListItem>
        <asp:ListItem Text="6" Value="6"></asp:ListItem>
        <asp:ListItem Text="7" Value="7"></asp:ListItem>
        <asp:ListItem Text="8" Value="8"></asp:ListItem>                                                                       
        </asp:DropDownList>
		<asp:Panel id="pnlCtrl"  runat="server"></asp:Panel>
        <input id="btnUpload" Visible="false" type="button" OnServerClick="btnUpload_OnClick"  value="Upload" runat="server" />
        <asp:Label id="lblText"  runat="server"></asp:Label>
    </form>
</body>
</html>


Screenshot

ASP.NET Upload

ASP.NET Upload






   
Share


ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท


ลองใช้ค้นหาข้อมูล


   


Bookmark.   
       
  By : ThaiCreate.Com Team (บทความเป็นลิขสิทธิ์ของเว็บไทยครีเอทห้ามนำเผยแพร่ ณ เว็บไซต์อื่น ๆ)
  Score Rating :  
  Create/Update Date : 2008-11-25 07:47:02 / 2009-06-03 07:39:28
  Download : Download  (C#) ASP.NET Upload & Create Control - FindControl
 Sponsored Links / Related

 
(C#) ASP.NET Upload file (HTMLInputFile)
Rating :

 
(C#) ASP.NET Upload file (HTMLInputFile - runat="server")
Rating :

 
(C#) ASP.NET Upload file (HTMLInputFile - Multiple upload) P.1
Rating :

 
(C#) ASP.NET Upload file (HTMLInputFile - Multiple upload) P.2
Rating :

 
(C#) ASP.NET Upload file (FileUpload Control)
Rating :

 
(C#) ASP.NET Upload & Multiple-FindControl
Rating :

 
(C#) ASP.NET Upload & Create Control - FindControl
Rating :

 
(C#) ASP.NET Upload file to Database
Rating :

 
(C#) ASP.NET Upload file & BLOB Image Binary
Rating :

 
(C#) ASP.NET Limit Max Size Upload file
Rating :

 
(C#) ASP.NET Restrict the types of files (extension)
Rating :


ThaiCreate.Com Forum


Comunity Forum Free Web Script
Jobs Freelance Free Uploads
Free Web Hosting Free Tools

สอน PHP ผ่าน Youtube ฟรี
สอน Android การเขียนโปรแกรม Android
สอน Windows Phone การเขียนโปรแกรม Windows Phone 7 และ 8
สอน iOS การเขียนโปรแกรม iPhone, iPad
สอน Java การเขียนโปรแกรม ภาษา Java
สอน Java GUI การเขียนโปรแกรม ภาษา Java GUI
สอน JSP การเขียนโปรแกรม ภาษา Java
สอน jQuery การเขียนโปรแกรม ภาษา jQuery
สอน .Net การเขียนโปรแกรม ภาษา .Net
Free Tutorial
สอน Google Maps Api
สอน Windows Service
สอน Entity Framework
สอน Android
สอน Java เขียน Java
Java GUI Swing
สอน JSP (Web App)
iOS (iPhone,iPad)
Windows Phone
Windows Azure
Windows Store
Laravel Framework
Yii PHP Framework
สอน jQuery
สอน jQuery กับ Ajax
สอน PHP OOP (Vdo)
Ajax Tutorials
SQL Tutorials
สอน SQL (Part 2)
JavaScript Tutorial
Javascript Tips
VBScript Tutorial
VBScript Validation
Microsoft Access
MySQL Tutorials
-- Stored Procedure
MariaDB Database
SQL Server Tutorial
SQL Server 2005
SQL Server 2008
SQL Server 2012
-- Stored Procedure
Oracle Database
-- Stored Procedure
SVN (Subversion)
แนวทางการทำ SEO
ปรับแต่งเว็บให้โหลดเร็ว


Hit Link
   







Load balance : Server 05
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่