2010-07-17 3 views
1

추가 된 컨트롤을 제거하려고합니다. 페이지에 업로드 컨트롤을 추가하는 마크 업은 다음과 같습니다.ASP.NET에서 추가 된 컨트롤을 제거합니다.

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <title>Multi File Upload</title> 
</head> 
<body> 
<form id="form1" runat="server" enctype="multipart/form-data"> 
<p id="upload-area"> 
    <input id="File1" type="file" runat="server" size="60" /> 
</p> 

<input id="AddFile" type="button" value="Add file" onclick="addFileUploadBox()" /> 
<br /> 
<br /> 
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> 
<p><asp:Button ID="btnSubmit" runat="server" Text="Upload Now" OnClick="btnSubmit_Click" /></p> 
<span id="Span1" runat="server" /> 
<script type="text/javascript"> 
function addFileUploadBox() 
{ 
    if (!document.getElementById || !document.createElement) 
     return false; 

    var uploadArea = document.getElementById ("upload-area"); 

    if (!uploadArea) 
     return; 

    var newLine = document.createElement ("br"); 
    uploadArea.appendChild (newLine); 

    var newUploadBox = document.createElement ("input"); 

    // Set up the new input for file uploads 
    newUploadBox.type = "file"; 
    newUploadBox.size = "60"; 

    // The new box needs a name and an ID 
    if (!addFileUploadBox.lastAssignedId) 
     addFileUploadBox.lastAssignedId = 100; 

    newUploadBox.setAttribute ("id", "dynamic" + addFileUploadBox.lastAssignedId); 
    newUploadBox.setAttribute ("name", "dynamic:" + addFileUploadBox.lastAssignedId); 
    uploadArea.appendChild (newUploadBox); 
    addFileUploadBox.lastAssignedId++; 
} 
</script> 
</form> 
</body> 
</html> 

감사합니다.

답변

관련 문제