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 > ASP.NET > ASP.NET Upload File > ASP.NET Upload & Create Control - FindControl



Clound SSD Virtual Server

ASP.NET Upload & Create Control - FindControl

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

Language Code : VB.NET || C#

Framework : 2,3,4

AspNetCreateFileUpload.aspx

<%@ Page Language="VB" %>
<script runat="server">

	Sub ddlNum_Changed(sender As Object, e As System.EventArgs)
        Dim i As Integer
        Dim fileUpload As FileUpload
		Dim lblBr As Label
        For i = 1 To Me.ddlNum.SelectedItem.Value
            fileUpload = New FileUpload
            With fileUpload
                .ID = "fiUpload" & i
            End With
			lblBr = New Label
			lblBr.Text = "<br>"
			Me.pnlCtrl.Controls.Add(fileUpload)
			Me.pnlCtrl.Controls.Add(lblBr)			
        Next

		IF Me.ddlNum.SelectedItem.Value > 0 Then
			Me.btnUpload.Visible = True
		Else
			Me.btnUpload.Visible = False
		End IF

		Me.form1.Enctype = "multipart/form-data"
	End Sub

    Sub btnUpload_OnClick(sender As Object, e As EventArgs)
			Dim i As Integer
			Dim myUpoad As HttpFileCollection = Request.Files
			Dim myFiles As HttpPostedFile
			For i = 0 To Me.ddlNum.SelectedItem.Value - 1
				myFiles = myUpoad(i)
				If myUpoad.Keys(i).ToString = ("fiUpload" & i + 1).ToString Then  '*** Check Control ***'
					If (myFiles.FileName) <> "" Then
						Dim strFileName = System.IO.Path.GetFileName(myFiles.FileName)
						myFiles.SaveAs(Server.MapPath("Myfiles/" & strFileName))
						Me.lblText.Text = Me.lblText.Text & strFileName & " Uploaded.<br>"
					End If
				End If
			Next
			Me.lblText.Visible = True
			Me.btnUpload.Visible = False
			Me.ddlNum.Visible = False
    End Sub
</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  ASP.NET Upload & Create Control - FindControl
 Sponsored Links / Related

 
ASP.NET Upload file (HTMLInputFile)
Rating :

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

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

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

 
ASP.NET Upload file (FileUpload Control)
Rating :

 
ASP.NET Upload & Multiple-FindControl
Rating :

 
ASP.NET Upload file to Database
Rating :

 
ASP.NET Upload file & BLOB Image Binary
Rating :

 
ASP.NET Limit Max Size Upload file
Rating :

 
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 02
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 อัตราราคา คลิกที่นี่