FileUpload クラス

定義

ユーザーがファイルを選択してサーバーにアップロードするためのテキスト ボックス コントロールと参照ボタンを表示します。

public ref class FileUpload : System::Web::UI::WebControls::WebControl
[System.Web.UI.ControlValueProperty("FileBytes")]
[System.Web.UI.ValidationProperty("FileName")]
public class FileUpload : System.Web.UI.WebControls.WebControl
[<System.Web.UI.ControlValueProperty("FileBytes")>]
[<System.Web.UI.ValidationProperty("FileName")>]
type FileUpload = class
    inherit WebControl
Public Class FileUpload
Inherits WebControl
継承
属性

ソース コードを含む Visual Studio Web サイト プロジェクトは、「 ダウンロード」のトピックに付属しています。

このセクションには、次の 4 つの例が含まれています。

  • 最初の例では、コードで指定されたパスにファイルを FileUpload 保存するコントロールを作成する方法を示します。

  • 2 番目の例では、アプリケーションのファイル システム内の指定したディレクトリにファイルを保存するコントロールを作成 FileUpload する方法を示します。

  • 3 番目の例では、指定したパスにファイルを FileUpload 保存し、アップロードできるファイルのサイズを制限するコントロールを作成する方法を示します。

  • 4 番目の例では、指定したパスにファイルを保存し、.docまたはファイル名拡張子を持つファイルのみをアップロードできるようにするコントロール.xls作成 FileUpload する方法を示します。

注意事項

これらの例では、コントロールの基本的な構文を FileUpload 示していますが、ファイルを保存する前に完了する必要があるすべての必要なエラー チェックを示しているわけではありません。 この例より完全なコード例については、「SaveAs」を参照してください。

次の例では、コードで指定されたパスにファイルを FileUpload 保存するコントロールを作成する方法を示します。 メソッドを SaveAs 呼び出して、サーバー上の指定したパスにファイルを保存します。

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<script runat="server">

  protected void UploadButton_Click(object sender, EventArgs e)
  {
    // Specify the path on the server to
    // save the uploaded file to.
    String savePath = @"c:\temp\uploads\";
 
    // Before attempting to perform operations
    // on the file, verify that the FileUpload 
    // control contains a file.
    if (FileUpload1.HasFile)
    {
      // Get the name of the file to upload.
      String fileName = FileUpload1.FileName;
      
      // Append the name of the file to upload to the path.
      savePath += fileName;
      

      // Call the SaveAs method to save the 
      // uploaded file to the specified path.
      // This example does not perform all
      // the necessary error checking.               
      // If a file with the same name
      // already exists in the specified path,  
      // the uploaded file overwrites it.
      FileUpload1.SaveAs(savePath);
      
      // Notify the user of the name of the file
      // was saved under.
      UploadStatusLabel.Text = "Your file was saved as " + fileName;
    }
    else
    {      
      // Notify the user that a file was not uploaded.
      UploadStatusLabel.Text = "You did not specify a file to upload.";
    }

  }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>FileUpload Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
       <h4>Select a file to upload:</h4>
   
       <asp:FileUpload id="FileUpload1"                 
           runat="server">
       </asp:FileUpload>
            
       <br /><br />
       
       <asp:Button id="UploadButton" 
           Text="Upload file"
           OnClick="UploadButton_Click"
           runat="server">
       </asp:Button>    
       
       <hr />
       
       <asp:Label id="UploadStatusLabel"
           runat="server">
       </asp:Label>        
    </div>
    </form>
</body>
</html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<script runat="server">
        
  Sub UploadButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            
    ' Specify the path on the server to
    ' save the uploaded file to.
    Dim savePath As String = "c:\temp\uploads\"
            
    ' Before attempting to perform operations
    ' on the file, verify that the FileUpload 
    ' control contains a file.
    If (FileUpload1.HasFile) Then
      ' Get the name of the file to upload.
      Dim fileName As String = FileUpload1.FileName
                      
      ' Append the name of the file to upload to the path.
      savePath += fileName
                
      ' Call the SaveAs method to save the 
      ' uploaded file to the specified path.
      ' This example does not perform all
      ' the necessary error checking.               
      ' If a file with the same name
      ' already exists in the specified path,  
      ' the uploaded file overwrites it.
      FileUpload1.SaveAs(savePath)
                
      ' Notify the user of the name the file
      ' was saved under.
      UploadStatusLabel.Text = "Your file was saved as " & fileName
                
    Else
      ' Notify the user that a file was not uploaded.
      UploadStatusLabel.Text = "You did not specify a file to upload."
    End If

  End Sub
       
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>FileUpload Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
       <h4>Select a file to upload:</h4>
   
       <asp:FileUpload id="FileUpload1"                 
           runat="server">
       </asp:FileUpload>
            
       <br /><br />
       
       <asp:Button id="UploadButton" 
           Text="Upload file"
           OnClick="UploadButton_Click"
           runat="server">
       </asp:Button>    
       
       <hr />
       
       <asp:Label id="UploadStatusLabel"
           runat="server">
       </asp:Label>        
    </div>
    </form>
</body>
</html>

次の例では、アプリケーションのファイル システム内の FileUpload 指定したディレクトリにファイルを保存するコントロールを作成する方法を示します。 プロパティは HttpRequest.PhysicalApplicationPath 、現在実行中のサーバー アプリケーションのルート ディレクトリの物理ファイル システム パスを取得するために使用されます。 SaveAsメソッドが呼び出され、サーバー上の指定したパスにファイルが保存されます。

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    protected void UploadButton_Click(object sender, EventArgs e)
    {
        // Save the uploaded file to an "Uploads" directory
        // that already exists in the file system of the 
        // currently executing ASP.NET application.  
        // Creating an "Uploads" directory isolates uploaded 
        // files in a separate directory. This helps prevent
        // users from overwriting existing application files by
        // uploading files with names like "Web.config".
        string saveDir = @"\Uploads\";

        // Get the physical file system path for the currently
        // executing application.
        string appPath = Request.PhysicalApplicationPath;

        // Before attempting to save the file, verify
        // that the FileUpload control contains a file.
        if (FileUpload1.HasFile)
        {
            string savePath = appPath + saveDir +
                Server.HtmlEncode(FileUpload1.FileName);
            
            // Call the SaveAs method to save the 
            // uploaded file to the specified path.
            // This example does not perform all
            // the necessary error checking.               
            // If a file with the same name
            // already exists in the specified path,  
            // the uploaded file overwrites it.
            FileUpload1.SaveAs(savePath);

            // Notify the user that the file was uploaded successfully.
            UploadStatusLabel.Text = "Your file was uploaded successfully.";

        }
        else
        {
            // Notify the user that a file was not uploaded.
            UploadStatusLabel.Text = "You did not specify a file to upload.";   
        }
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>FileUpload Class Example</title>
</head>
<body>
    <h3>FileUpload Class Example: Save To Application Directory</h3>
    <form id="form1" runat="server">
    <div>
       <h4>Select a file to upload:</h4>
   
       <asp:FileUpload id="FileUpload1"                 
           runat="server">
       </asp:FileUpload>
            
       <br/><br/>
       
       <asp:Button id="UploadButton" 
           Text="Upload file"
           OnClick="UploadButton_Click"
           runat="server">
       </asp:Button>    
       
       <hr />
       
       <asp:Label id="UploadStatusLabel"
           runat="server">
       </asp:Label>           
    </div>
    </form>
</body>
</html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    Sub UploadButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            
        ' Save the uploaded file to an "Uploads" directory
        ' that already exists in the file system of the 
        ' currently executing ASP.NET application.  
        ' Creating an "Uploads" directory isolates uploaded 
        ' files in a separate directory. This helps prevent
        ' users from overwriting existing application files by
        ' uploading files with names like "Web.config".
        Dim saveDir As String = "\Uploads\"
           
        ' Get the physical file system path for the currently
        ' executing application.
        Dim appPath As String = Request.PhysicalApplicationPath
            
        ' Before attempting to save the file, verify
        ' that the FileUpload control contains a file.
        If (FileUpload1.HasFile) Then
            Dim savePath As String = appPath + saveDir + _
                Server.HtmlEncode(FileUpload1.FileName)
                        
            ' Call the SaveAs method to save the 
            ' uploaded file to the specified path.
            ' This example does not perform all
            ' the necessary error checking.               
            ' If a file with the same name
            ' already exists in the specified path,  
            ' the uploaded file overwrites it.
            FileUpload1.SaveAs(savePath)
                
            ' Notify the user that the file was uploaded successfully.
            UploadStatusLabel.Text = "Your file was uploaded successfully."

        Else
            ' Notify the user that a file was not uploaded.
            UploadStatusLabel.Text = "You did not specify a file to upload."
        End If

    End Sub
       
</script>
    
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>FileUpload Class Example</title>
</head>
<body>
   <h3>FileUpload Class Example: Save To Application Directory</h3>
   <form id="form1" runat="server">
   <div>   
       <h4>Select a file to upload:</h4>
   
       <asp:FileUpload id="FileUpload1"                 
           runat="server">
       </asp:FileUpload>
            
       <br/><br/>
       
       <asp:Button id="UploadButton" 
           Text="Upload file"
           OnClick="UploadButton_Click"
           runat="server">
       </asp:Button>    
       
       <hr />
       
       <asp:Label id="UploadStatusLabel"
           runat="server">
       </asp:Label>       
         
   </div>
   </form>
</body>
</html>

次の例では、コードで指定されたパスにファイルを保存するコントロールを作成 FileUpload する方法を示します。 コントロールは、アップロードできるファイルのサイズを 2 MB に制限します。 プロパティは PostedFile 、基になる ContentLength プロパティにアクセスし、ファイルのサイズを返すために使用されます。 アップロードするファイルのサイズが 2 MB 未満の場合は、 メソッドが呼び出され、 SaveAs サーバー上の指定したパスにファイルが保存されます。 アプリケーション コードで最大ファイル サイズの設定を確認するだけでなく、httpRuntime 要素の属性を、アプリケーションの構成ファイルで許容される最大サイズに設定maxRequestLengthできます。

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    protected void UploadButton_Click(object sender, EventArgs e)
    {
        // Specify the path on the server to
        // save the uploaded file to.
        string savePath = @"c:\temp\uploads\";
                       
        // Before attempting to save the file, verify
        // that the FileUpload control contains a file.
        if (FileUpload1.HasFile)
        {                
            // Get the size in bytes of the file to upload.
            int fileSize = FileUpload1.PostedFile.ContentLength;
          
            // Allow only files less than 2,100,000 bytes (approximately 2 MB) to be uploaded.
            if (fileSize < 2100000)
            {
                        
                // Append the name of the uploaded file to the path.
                savePath += Server.HtmlEncode(FileUpload1.FileName);

                // Call the SaveAs method to save the 
                // uploaded file to the specified path.
                // This example does not perform all
                // the necessary error checking.               
                // If a file with the same name
                // already exists in the specified path,  
                // the uploaded file overwrites it.
                FileUpload1.SaveAs(savePath);
                
                // Notify the user that the file was uploaded successfully.
                UploadStatusLabel.Text = "Your file was uploaded successfully.";
            }
            else
            {
                // Notify the user why their file was not uploaded.
                UploadStatusLabel.Text = "Your file was not uploaded because " + 
                                         "it exceeds the 2 MB size limit.";
            }
        }   
        else
        {
            // Notify the user that a file was not uploaded.
            UploadStatusLabel.Text = "You did not specify a file to upload.";
        }
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>FileUpload Class Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
       <h4>Select a file to upload:</h4>
   
       <asp:FileUpload id="FileUpload1"                 
           runat="server">
       </asp:FileUpload>
            
       <br/><br/>
       
       <asp:Button id="UploadButton" 
           Text="Upload file"
           OnClick="UploadButton_Click"
           runat="server">
       </asp:Button>
       
       <hr />
       
       <asp:Label id="UploadStatusLabel"
           runat="server">
       </asp:Label>
           
    </div>
    </form>
</body>
</html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    Protected Sub UploadButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        
        ' Specify the path on the server to
        ' save the uploaded file to.
        Dim savePath As String = "c:\temp\uploads\"
                       
        ' Before attempting to save the file, verify
        ' that the FileUpload control contains a file.
        If (FileUpload1.HasFile) Then
                
            ' Get the size in bytes of the file to upload.
            Dim fileSize As Integer = FileUpload1.PostedFile.ContentLength
          
            ' Allow only files less than 2,100,000 bytes (approximately 2 MB) to be uploaded.
            If (fileSize < 2100000) Then
                        
                ' Append the name of the uploaded file to the path.
                savePath += Server.HtmlEncode(FileUpload1.FileName)

                ' Call the SaveAs method to save the 
                ' uploaded file to the specified path.
                ' This example does not perform all
                ' the necessary error checking.               
                ' If a file with the same name
                ' already exists in the specified path,  
                ' the uploaded file overwrites it.
                FileUpload1.SaveAs(savePath)
                
                ' Notify the user that the file was uploaded successfully.
                UploadStatusLabel.Text = "Your file was uploaded successfully."
            
            Else
                ' Notify the user why their file was not uploaded.
                UploadStatusLabel.Text = "Your file was not uploaded because " + _
                                         "it exceeds the 2 MB size limit."
            End If
                
        Else
            ' Notify the user that a file was not uploaded.
            UploadStatusLabel.Text = "You did not specify a file to upload."
        End If

    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>FileUpload Class Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
       <h4>Select a file to upload:</h4>
   
       <asp:FileUpload id="FileUpload1"                 
           runat="server">
       </asp:FileUpload>
            
       <br/><br/>
       
       <asp:Button id="UploadButton" 
           Text="Upload file"
           OnClick="UploadButton_Click"
           runat="server">
       </asp:Button>
       
       <hr />
       
       <asp:Label id="UploadStatusLabel"
           runat="server">
       </asp:Label>
           
    </div>
    </form>
</body>
</html>

次の例では、コードで指定されたパスにファイルを保存するコントロールを作成 FileUpload する方法を示します。 この例では、.docまたは.xlsファイル名拡張子を持つファイルのみをアップロードできます。 Path.GetExtensionメソッドは、アップロードするファイルの拡張子を返すために呼び出されます。 ファイル名拡張子が.docまたは.xlsの場合は、 メソッドが呼び出され、 SaveAs サーバー上の指定したパスにファイルが保存されます。

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    protected void UploadBtn_Click(object sender, EventArgs e)
    {
        // Specify the path on the server to
        // save the uploaded file to.
        string savePath = @"c:\temp\uploads";

        // Before attempting to save the file, verify
        // that the FileUpload control contains a file.
        if (FileUpload1.HasFile)
        {
            // Get the name of the file to upload.
            string fileName = Server.HtmlEncode(FileUpload1.FileName);

            // Get the extension of the uploaded file.
            string extension = System.IO.Path.GetExtension(fileName);
            
            // Allow only files with .doc or .xls extensions
            // to be uploaded.
            if ((extension == ".doc") || (extension == ".xls"))
            {
                // Append the name of the file to upload to the path.
                savePath += fileName;

                // Call the SaveAs method to save the 
                // uploaded file to the specified path.
                // This example does not perform all
                // the necessary error checking.               
                // If a file with the same name
                // already exists in the specified path,  
                // the uploaded file overwrites it.
                FileUpload1.SaveAs(savePath);
                
                // Notify the user that their file was successfully uploaded.
                UploadStatusLabel.Text = "Your file was uploaded successfully.";
            }
            else
            {
                // Notify the user why their file was not uploaded.
                UploadStatusLabel.Text = "Your file was not uploaded because " + 
                                         "it does not have a .doc or .xls extension.";
            }

        }

    }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>FileUpload Class Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h4>Select a file to upload:</h4>
       
        <asp:FileUpload id="FileUpload1"                 
            runat="server">
        </asp:FileUpload>
            
        <br/><br/>
       
        <asp:Button id="UploadBtn" 
            Text="Upload file"
            OnClick="UploadBtn_Click"
            runat="server">
        </asp:Button>    
       
        <hr />
       
        <asp:Label id="UploadStatusLabel"
            runat="server">
        </asp:Label>     
    </div>
    </form>
</body>
</html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    Protected Sub UploadBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        ' Specify the path on the server to
        ' save the uploaded file to.
        Dim savePath As String = "c:\temp\uploads\"
            
        ' Before attempting to save the file, verify
        ' that the FileUpload control contains a file.
        If (FileUpload1.HasFile) Then
            
            ' Get the name of the file to upload.
            Dim fileName As String = Server.HtmlEncode(FileUpload1.FileName)
            
            ' Get the extension of the uploaded file.
            Dim extension As String = System.IO.Path.GetExtension(fileName)
            
            ' Allow only files with .doc or .xls extensions
            ' to be uploaded.
            If (extension = ".doc") Or (extension = ".xls") Then
                        
                ' Append the name of the file to upload to the path.
                savePath += fileName
            
                ' Call the SaveAs method to save the 
                ' uploaded file to the specified path.
                ' This example does not perform all
                ' the necessary error checking.               
                ' If a file with the same name
                ' already exists in the specified path,  
                ' the uploaded file overwrites it.
                FileUpload1.SaveAs(savePath)
                
                ' Notify the user that their file was successfully uploaded.
                UploadStatusLabel.Text = "Your file was uploaded successfully."
            
            Else
                ' Notify the user why their file was not uploaded.
                UploadStatusLabel.Text = "Your file was not uploaded because " + _
                                         "it does not have a .doc or .xls extension."
            End If
                
        Else
            ' Notify the user that a file was not uploaded.
            UploadStatusLabel.Text = "You did not specify a file to upload."
        End If
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>FileUpload Class Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h4>Select a file to upload:</h4>
       
        <asp:FileUpload id="FileUpload1"                 
            runat="server">
        </asp:FileUpload>
            
        <br/><br/>
       
        <asp:Button id="UploadBtn" 
            Text="Upload file"
            OnClick="UploadBtn_Click"
            runat="server">
        </asp:Button>    
       
        <hr />
       
        <asp:Label id="UploadStatusLabel"
            runat="server">
        </asp:Label>     
    </div>
    </form>
</body>
</html>

注釈

このトピックの内容:

はじめに

クラスには FileUpload 、ユーザーがクライアント上のファイルを選択して Web サーバーにアップロードできるようにするテキスト ボックス コントロールと参照ボタンが表示されます。 ユーザーは、ローカル コンピューター上のファイルの完全パス (たとえば、 C:\MyFiles\TestFile.txt) をコントロールのテキスト ボックスに入力して、アップロードするファイルを指定します。 または、[ 参照 ] ボタンをクリックし、[ファイルの選択] ダイアログ ボックスでファイルを検索して、ファイルを 選択 することもできます。

プロパティを FileName 使用して、 コントロールを使用してアップロードするクライアント上のファイルの名前を FileUpload 取得します。 このプロパティが返すファイル名には、クライアント上のファイルのパスは含まれません。

プロパティは FileContentStream アップロードするファイルを指す オブジェクトを取得します。 ファイルの内容にバイトとしてアクセスするには、このプロパティを使用します。 たとえば、 プロパティによってFileContent返される オブジェクトをStream使用して、ファイルの内容をバイトとして読み取り、バイト配列に格納できます。 または、 プロパティを FileBytes 使用して、ファイル内のすべてのバイトを取得できます。

プロパティは PostedFile 、アップロードするファイルの基になる HttpPostedFile オブジェクトを取得します。 このプロパティを使用して、ファイルの追加のプロパティにアクセスできます。 プロパティは ContentLength 、ファイルの長さを取得します。 プロパティは ContentType 、ファイルの MIME コンテンツ タイプを取得します。 さらに、 プロパティをPostedFile使用して、プロパティ、プロパティ、InputStreamおよび メソッドにSaveAsアクセスFileNameできます。 ただし、 プロパティ、プロパティ、FileContentおよび メソッドでもFileName同じ機能がSaveAs提供されます。

アップロードしたファイルの保存

ユーザーが FileUpload アップロードするファイルを選択した後、コントロールによってファイルがサーバーに自動的に保存されることはありません。 ユーザーが指定したファイルを送信できるように、コントロールまたはメカニズムを明示的に指定する必要があります。 たとえば、ユーザーがファイルをアップロードするためにクリックするボタンを指定できます。 指定したファイルを保存するために記述するコードは、 メソッドを SaveAs 呼び出す必要があります。これにより、ファイルの内容がサーバー上の指定したパスに保存されます。 通常、 メソッドは、 SaveAs サーバーへのポストバックを発生させるイベントのイベント処理メソッドで呼び出されます。 たとえば、ファイルを送信するボタンを指定した場合、click イベントのイベント処理メソッド内にファイルを保存するコードを含めることができます。

メソッドを SaveAs 呼び出してファイルをサーバーに保存する前に、 プロパティを HasFile 使用して、コントロールにファイルが FileUpload 含まれていることを確認します。 が HasFile を返す場合は true、 メソッドを SaveAs 呼び出します。 が返された false場合は、コントロールにファイルが含まれていないことを示すメッセージをユーザーに表示します。 アップロードするファイルが存在するかどうかを判断するには、 プロパティをチェックPostedFileしないでください。既定では、このプロパティには 0 バイトが含まれているためです。 その結果、コントロールが FileUpload 空白の場合でも、 PostedFile プロパティは null 以外の値を返します。

セキュリティに関する考慮事項

メソッドを SaveAs 呼び出すときは、アップロードしたファイルを保存するディレクトリの完全なパスを指定する必要があります。 アプリケーション コードでパスを明示的に指定しない場合、ユーザーがファイルをアップロードしようとすると例外がスローされます。 この動作は、ユーザーがアプリケーションのディレクトリ構造内の任意の場所に書き込むのを防ぎ、機密性の高いルート ディレクトリにアクセスできないようにすることで、サーバー上のファイルをセキュリティで保護するのに役立ちます。

メソッドは SaveAs 、アップロードされたファイルを指定したディレクトリに書き込みます。 したがって、ASP.NET アプリケーションは、サーバー上のディレクトリへの書き込みアクセス権を持っている必要があります。 アプリケーションで書き込みアクセスを取得するには、2 つの方法があります。 アップロードされたファイルが保存されるディレクトリ内で、アプリケーションが実行されているアカウントへの書き込みアクセス権を明示的に付与できます。 または、ASP.NET アプリケーションに付与される信頼レベルを上げることができます。 アプリケーションの実行中のディレクトリへの書き込みアクセス権を取得するには、信頼レベルが値に AspNetHostingPermission 設定されたオブジェクトをアプリケーションに AspNetHostingPermissionLevel.Medium 付与する必要があります。 信頼レベルを上げると、サーバー上のリソースへのアプリケーションのアクセスが増加します。 アプリケーションの制御を取得する悪意のあるユーザーも、この高いレベルの信頼の下で実行できるため、これはセキュリティで保護されたアプローチではないことに注意してください。 アプリケーションの実行に必要な最小限の特権を持つユーザーのコンテキストで、ASP.NET アプリケーションを実行することをお勧めします。 ASP.NET アプリケーションのセキュリティの詳細については、「 Web アプリケーションの基本的なセキュリティ プラクティス 」および「 信頼レベルとポリシー ファイルの ASP.NET」を参照してください。

メモリの制限事項

サービス拒否攻撃から保護する方法の 1 つは、 コントロールを使用してアップロードできるファイルのサイズを FileUpload 制限することです。 アップロードするファイルの種類に適したサイズ制限を設定する必要があります。 既定のサイズ制限は 4096 キロバイト (KB)、または 4 メガバイト (MB) です。 httpRuntime 要素の 属性を設定maxRequestLengthすることで、より大きなファイルのアップロードを許可できます。 アプリケーション全体で許容される最大ファイル サイズを大きくするには、Web.config ファイルで 属性を設定 maxRequestLength します。 指定したページで許容される最大ファイル サイズを増やすには、Web.config 内の 要素内に 属性をlocation設定maxRequestLengthします。例については、「location 要素 (ASP.NET 設定スキーマ)」を参照してください。

大きなファイルをアップロードすると、ユーザーに次のエラー メッセージが表示される場合もあります。

aspnet_wp.exe (PID: 1520) was recycled because memory consumption exceeded 460 MB (60 percent of available RAM).

ユーザーがこのエラー メッセージを検出した場合は、アプリケーションの memoryLimit Web.config ファイルの要素の processModel 内の 属性の値を増やします。 属性は memoryLimit 、ワーカー プロセスで使用できるメモリの最大量を指定します。 ワーカー プロセスが金額を memoryLimit 超えた場合は、それを置き換える新しいプロセスが作成され、現在のすべての要求が新しいプロセスに再割り当てされます。

アップロードするファイルをメモリに一時的に格納するか、要求の処理中にサーバーに格納するかを制御するには、httpRuntime 要素の 属性を設定requestLengthDiskThresholdします。 この属性を使用すると、入力ストリーム バッファーのサイズを管理できます。 既定値は 256 バイトです。 指定する値は、 属性に指定 maxRequestLength した値を超えてはなりません。

FileUpload コントロールと UpdatePanel コントロールの使用

コントロールは FileUpload ポストバック シナリオでのみ使用するように設計されており、部分ページ レンダリング中の非同期ポストバック シナリオでは使用されません。 コントロール内でコントロールを FileUpload 使用する UpdatePanel 場合は、パネルのオブジェクトであるコントロールを使用してファイルを PostBackTrigger アップロードする必要があります。 UpdatePanel コントロールは、ページ全体をポストバックで更新するのではなく、ページの選択した領域を更新するために使用されます。 詳細については、「 UpdatePanel コントロールの概要 」および「 部分ページ レンダリングの概要」を参照してください

宣言構文

<asp:FileUpload  
    AccessKey="string"  
    BackColor="color name|#dddddd"  
    BorderColor="color name|#dddddd"  
    BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|Groove|Ridge|  
        Inset|Outset"  
    BorderWidth="size"  
    CssClass="string"  
    Enabled="True|False"  
    EnableTheming="True|False"  
    EnableViewState="True|False"  
    Font-Bold="True|False"  
    Font-Italic="True|False"  
    Font-Names="string"  
    Font-Overline="True|False"  
    Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|Medium|  
        Large|X-Large|XX-Large"  
    Font-Strikeout="True|False"  
    Font-Underline="True|False"  
    ForeColor="color name|#dddddd"  
    Height="size"  
    ID="string"  
    OnDataBinding="DataBinding event handler"  
    OnDisposed="Disposed event handler"  
    OnInit="Init event handler"  
    OnLoad="Load event handler"  
    OnPreRender="PreRender event handler"  
    OnUnload="Unload event handler"  
    runat="server"  
    SkinID="string"  
    Style="string"  
    TabIndex="integer"  
    ToolTip="string"  
    Visible="True|False"  
    Width="size"  
/>  

コンストラクター

FileUpload()

FileUpload クラスの新しいインスタンスを初期化します。

プロパティ

AccessKey

Web サーバー コントロールにすばやく移動できるアクセス キーを取得または設定します。

(継承元 WebControl)
Adapter

コントロール用のブラウザー固有のアダプターを取得します。

(継承元 Control)
AllowMultiple

複数のファイルをアップロード対象に選択できるかどうかを示す値を取得または設定します。

AppRelativeTemplateSourceDirectory

このコントロールが含まれている Page オブジェクトまたは UserControl オブジェクトのアプリケーション相対の仮想ディレクトリを取得または設定します。

(継承元 Control)
Attributes

コントロールのプロパティに対応しない任意の属性 (表示専用) のコレクションを取得します。

(継承元 WebControl)
BackColor

Web サーバー コントロールの背景色を取得または設定します。

(継承元 WebControl)
BindingContainer

このコントロールのデータ バインディングを格納しているコントロールを取得します。

(継承元 Control)
BorderColor

Web コントロールの境界線の色を取得または設定します。

(継承元 WebControl)
BorderStyle

Web サーバー コントロールの境界線スタイルを取得または設定します。

(継承元 WebControl)
BorderWidth

Web サーバー コントロールの境界線の幅を取得または設定します。

(継承元 WebControl)
ChildControlsCreated

サーバー コントロールの子コントロールが作成されたかどうかを示す値を取得します。

(継承元 Control)
ClientID

ASP.NET によって生成される HTML マークアップのコントロール ID を取得します。

(継承元 Control)
ClientIDMode

ClientID プロパティの値を生成するために使用されるアルゴリズムを取得または設定します。

(継承元 Control)
ClientIDSeparator

ClientID プロパティで使用される区切り記号を表す文字値を取得します。

(継承元 Control)
Context

現在の Web 要求に対するサーバー コントロールに関連付けられている HttpContext オブジェクトを取得します。

(継承元 Control)
Controls

UI 階層内の指定されたサーバー コントロールの子コントロールを表す ControlCollection オブジェクトを取得します。

(継承元 Control)
ControlStyle

Web サーバー コントロールのスタイルを取得します。 このプロパティは、主にコントロールの開発者によって使用されます。

(継承元 WebControl)
ControlStyleCreated

Style オブジェクトが ControlStyle プロパティに対して作成されたかどうかを示す値を取得します。 このプロパティは、主にコントロールの開発者によって使用されます。

(継承元 WebControl)
CssClass

クライアントで Web サーバー コントロールによって表示されるカスケード スタイル シート (CSS: Cascading Style Sheet) クラスを取得または設定します。

(継承元 WebControl)
DataItemContainer

名前付けコンテナーが IDataItemContainer を実装している場合、名前付けコンテナーへの参照を取得します。

(継承元 Control)
DataKeysContainer

名前付けコンテナーが IDataKeysControl を実装している場合、名前付けコンテナーへの参照を取得します。

(継承元 Control)
DesignMode

コントロールがデザイン サーフェイスで使用されているかどうかを示す値を取得します。

(継承元 Control)
Enabled

Web サーバー コントロールを有効にするかどうかを示す値を取得または設定します。

(継承元 WebControl)
EnableTheming

テーマがこのコントロールに適用されるかどうかを示す値を取得または設定します。

(継承元 WebControl)
EnableViewState

要求元クライアントに対して、サーバー コントロールがそのビュー状態と、そこに含まれる任意の子のコントロールのビュー状態を保持するかどうかを示す値を取得または設定します。

(継承元 Control)
Events

コントロールのイベント ハンドラー デリゲートのリストを取得します。 このプロパティは読み取り専用です。

(継承元 Control)
FileBytes

FileUpload コントロールを使用して、指定したファイルに格納されているバイトの配列を取得します。

FileContent

Stream コントロールを使用して、アップロードするファイルを指す FileUpload オブジェクトを取得します。

FileName

FileUpload コントロールを使用して、アップロードする、クライアント上のファイルの名前を取得します。

Font

Web サーバー コントロールに関連付けられたフォント プロパティを取得します。

(継承元 WebControl)
ForeColor

Web サーバー コントロールの前景色 (通常はテキストの色) を取得または設定します。

(継承元 WebControl)
HasAttributes

コントロールに属性セットがあるかどうかを示す値を取得します。

(継承元 WebControl)
HasChildViewState

現在のサーバー コントロールの子コントロールが、保存されたビューステートの設定を持っているかどうかを示す値を取得します。

(継承元 Control)
HasFile

ファイルが FileUpload コントロールに格納されているかどうかを示す値を取得します。

HasFiles

アップロードされたファイルがあるかどうかを示す値を取得します。

Height

Web サーバー コントロールの高さを取得または設定します。

(継承元 WebControl)
ID

サーバー コントロールに割り当てられたプログラム ID を取得または設定します。

(継承元 Control)
IdSeparator

コントロール ID を区別するために使用する文字を取得します。

(継承元 Control)
IsChildControlStateCleared

このコントロールに含まれているコントロールに、コントロールの状態が設定されているかどうかを示す値を取得します。

(継承元 Control)
IsEnabled

コントロールが有効かどうかを示す値を取得します。

(継承元 WebControl)
IsTrackingViewState

サーバー コントロールがビューステートの変更を保存しているかどうかを示す値を取得します。

(継承元 Control)
IsViewStateEnabled

このコントロールでビューステートが有効かどうかを示す値を取得します。

(継承元 Control)
LoadViewStateByID

コントロールがインデックスではなく ID によりビューステートの読み込みを行うかどうかを示す値を取得します。

(継承元 Control)
NamingContainer

同じ ID プロパティ値を持つ複数のサーバー コントロールを区別するための一意の名前空間を作成する、サーバー コントロールの名前付けコンテナーへの参照を取得します。

(継承元 Control)
Page

サーバー コントロールを含んでいる Page インスタンスへの参照を取得します。

(継承元 Control)
Parent

ページ コントロールの階層構造における、サーバー コントロールの親コントロールへの参照を取得します。

(継承元 Control)
PostedFile

HttpPostedFile コントロールを使用して、アップロードされたファイルの基になる FileUpload オブジェクトを取得します。

PostedFiles

アップロードされたファイルのコレクションを取得します。

RenderingCompatibility

レンダリングされる HTML と互換性がある ASP.NET のバージョンを表す値を取得します。

(継承元 Control)
Site

デザイン サーフェイスに現在のコントロールを表示するときに、このコントロールをホストするコンテナーに関する情報を取得します。

(継承元 Control)
SkinID

コントロールに適用するスキンを取得または設定します。

(継承元 WebControl)
Style

Web サーバー コントロールの外側のタグにスタイル属性として表示されるテキスト属性のコレクションを取得します。

(継承元 WebControl)
SupportsDisabledAttribute

コントロールの disabled プロパティが IsEnabled の場合、レンダリングされた HTML 要素の false 属性を "無効" に設定するかどうかを示す値を取得します。

(継承元 WebControl)
TabIndex

Web サーバー コントロールのタブ インデックスを取得または設定します。

(継承元 WebControl)
TagKey

この Web サーバー コントロールに対応する HtmlTextWriterTag 値を取得します。 このプロパティは、主にコントロールの開発者によって使用されます。

(継承元 WebControl)
TagName

コントロール タグの名前を取得します。 このプロパティは、主にコントロールの開発者によって使用されます。

(継承元 WebControl)
TemplateControl

このコントロールを格納しているテンプレートへの参照を取得または設定します。

(継承元 Control)
TemplateSourceDirectory

現在のサーバー コントロールを格納している Page または UserControl の仮想ディレクトリを取得します。

(継承元 Control)
ToolTip

マウス ポインターが Web サーバー コントロールの上を移動したときに表示されるテキストを取得または設定します。

(継承元 WebControl)
UniqueID

階層構造で修飾されたサーバー コントロールの一意の ID を取得します。

(継承元 Control)
ValidateRequestMode

ブラウザーからのクライアント入力の安全性をコントロールで調べるかどうかを示す値を取得または設定します。

(継承元 Control)
ViewState

同一のページに対する複数の要求にわたって、サーバー コントロールのビューステートを保存し、復元できるようにする状態情報のディクショナリを取得します。

(継承元 Control)
ViewStateIgnoresCase

StateBag オブジェクトが大文字小文字を区別しないかどうかを示す値を取得します。

(継承元 Control)
ViewStateMode

このコントロールのビューステート モードを取得または設定します。

(継承元 Control)
Visible

サーバー コントロールがページ上の UI としてレンダリングされているかどうかを示す値を取得または設定します。

(継承元 Control)
Width

Web サーバー コントロールの幅を取得または設定します。

(継承元 WebControl)

メソッド

AddAttributesToRender(HtmlTextWriter)

指定した HtmlTextWriter オブジェクトに表示する FileUpload コントロールの HTML 属性とスタイルを追加します。

AddedControl(Control, Int32)

子コントロールが Control オブジェクトの Controls コレクションに追加された後に呼び出されます。

(継承元 Control)
AddParsedSubObject(Object)

XML または HTML のいずれかの要素が解析されたことをサーバー コントロールに通知し、サーバー コントロールの ControlCollection オブジェクトに要素を追加します。

(継承元 Control)
ApplyStyle(Style)

指定したスタイルの空白以外の要素を Web コントロールにコピーして、コントロールの既存のスタイル要素を上書きします。 このメソッドは、主にコントロールの開発者によって使用されます。

(継承元 WebControl)
ApplyStyleSheetSkin(Page)

ページのスタイル シートに定義されたスタイル プロパティをコントロールに適用します。

(継承元 Control)
BeginRenderTracing(TextWriter, Object)

レンダリング データのデザイン時のトレースを開始します。

(継承元 Control)
BuildProfileTree(String, Boolean)

ページのトレースが有効な場合、サーバー コントロールに関する情報を収集し、これを表示するために Trace プロパティに渡します。

(継承元 Control)
ClearCachedClientID()

キャッシュされた ClientID 値を null に設定します。

(継承元 Control)
ClearChildControlState()

サーバー コントロールのすべての子コントロールについて、コントロールの状態情報を削除します。

(継承元 Control)
ClearChildState()

サーバー コントロールのすべての子コントロールのビューステート情報およびコントロールの状態情報を削除します。

(継承元 Control)
ClearChildViewState()

サーバー コントロールのすべての子コントロールのビューステート情報を削除します。

(継承元 Control)
ClearEffectiveClientIDMode()

現在のコントロール インスタンスおよびすべての子コントロールの ClientIDMode プロパティを Inherit に設定します。

(継承元 Control)
CopyBaseAttributes(WebControl)

指定した Web サーバー コントロールから、Style オブジェクトでカプセル化されていないプロパティをこのメソッドの呼び出し元の Web サーバー コントロールにコピーします。 このメソッドは、主にコントロールの開発者によって使用されます。

(継承元 WebControl)
CreateChildControls()

ASP.NET ページ フレームワークによって呼び出され、ポストバックまたはレンダリングの準備として、合成ベースの実装を使うサーバー コントロールに対し、それらのコントロールに含まれる子コントロールを作成するように通知します。

(継承元 Control)
CreateControlCollection()

サーバー コントロールの子コントロール (リテラルとサーバーの両方) を保持する新しい ControlCollection オブジェクトを作成します。

(継承元 Control)
CreateControlStyle()

WebControl クラスで、すべてのスタイル関連プロパティを実装するために内部的に使用されるスタイル オブジェクトを作成します。 このメソッドは、主にコントロールの開発者によって使用されます。

(継承元 WebControl)
DataBind()

呼び出されたサーバー コントロールとそのすべての子コントロールにデータ ソースをバインドします。

(継承元 Control)
DataBind(Boolean)

DataBinding イベントを発生させるオプションを指定して、呼び出されたサーバー コントロールとそのすべての子コントロールにデータ ソースをバインドします。

(継承元 Control)
DataBindChildren()

データ ソースをサーバー コントロールの子コントロールにバインドします。

(継承元 Control)
Dispose()

サーバー コントロールが、メモリから解放される前に最終的なクリーンアップを実行できるようにします。

(継承元 Control)
EndRenderTracing(TextWriter, Object)

レンダリング データのデザイン時のトレースを終了します。

(継承元 Control)
EnsureChildControls()

サーバー コントロールに子コントロールが含まれているかどうかを確認します。 含まれていない場合、子コントロールを作成します。

(継承元 Control)
EnsureID()

ID が割り当てられていないコントロールの ID を作成します。

(継承元 Control)
Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
FindControl(String)

指定した id パラメーターを使用して、サーバー コントロールの現在の名前付けコンテナーを検索します。

(継承元 Control)
FindControl(String, Int32)

指定した id および検索に役立つ pathOffset パラメーターに指定された整数を使用して、サーバー コントロールの現在の名前付けコンテナーを検索します。 この形式の FindControl メソッドはオーバーライドしないでください。

(継承元 Control)
Focus()

コントロールに入力フォーカスを設定します。

(継承元 Control)
GetDesignModeState()

コントロールのデザイン時データを取得します。

(継承元 Control)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetRouteUrl(Object)

ルート パラメーターのセットに対応する URL を取得します。

(継承元 Control)
GetRouteUrl(RouteValueDictionary)

ルート パラメーターのセットに対応する URL を取得します。

(継承元 Control)
GetRouteUrl(String, Object)

ルート パラメーターのセットおよびルート名に対応する URL を取得します。

(継承元 Control)
GetRouteUrl(String, RouteValueDictionary)

ルート パラメーターのセットおよびルート名に対応する URL を取得します。

(継承元 Control)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
GetUniqueIDRelativeTo(Control)

指定されたコントロールの UniqueID プロパティのプレフィックス部分を返します。

(継承元 Control)
HasControls()

サーバー コントロールに子コントロールが含まれているかどうかを確認します。

(継承元 Control)
HasEvents()

コントロールまたは子コントロールに対してイベントが登録されているかどうかを示す値を返します。

(継承元 Control)
IsLiteralContent()

サーバー コントロールがリテラルな内容だけを保持しているかどうかを決定します。

(継承元 Control)
LoadControlState(Object)

SaveControlState() メソッドによって保存された前回のページ要求からコントロールの状態情報を復元します。

(継承元 Control)
LoadViewState(Object)

SaveViewState() メソッドで保存された前の要求からビュー ステート情報を復元します。

(継承元 WebControl)
MapPathSecure(String)

仮想パス (絶対パスまたは相対パス) の割り当て先の物理パスを取得します。

(継承元 Control)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
MergeStyle(Style)

指定したスタイルの空白以外の要素を Web コントロールにコピーしますが、コントロールの既存のスタイル要素は上書きしません。 このメソッドは、主にコントロールの開発者によって使用されます。

(継承元 WebControl)
OnBubbleEvent(Object, EventArgs)

サーバー コントロールのイベントをページの UI サーバー コントロールの階層構造に渡すかどうかを決定します。

(継承元 Control)
OnDataBinding(EventArgs)

DataBinding イベントを発生させます。

(継承元 Control)
OnInit(EventArgs)

Init イベントを発生させます。

(継承元 Control)
OnLoad(EventArgs)

Load イベントを発生させます。

(継承元 Control)
OnPreRender(EventArgs)

FileUpload コントロールの PreRender イベントを発生させます。

OnUnload(EventArgs)

Unload イベントを発生させます。

(継承元 Control)
OpenFile(String)

ファイルの読み込みで使用される Stream を取得します。

(継承元 Control)
RaiseBubbleEvent(Object, EventArgs)

イベントのソースおよびその情報をコントロールの親に割り当てます。

(継承元 Control)
RemovedControl(Control)

Control オブジェクトの Controls コレクションから子コントロールが削除された後に呼び出されます。

(継承元 Control)
Render(HtmlTextWriter)

指定された FileUpload オブジェクトに HtmlTextWriter コントロールの内容を渡します。このオブジェクトが、クライアントに表示する内容を書き込みます。

RenderBeginTag(HtmlTextWriter)

コントロールの HTML 開始タグを指定したライターに表示します。 このメソッドは、主にコントロールの開発者によって使用されます。

(継承元 WebControl)
RenderChildren(HtmlTextWriter)

提供された HtmlTextWriter オブジェクトに対してサーバー コントロールの子のコンテンツを出力すると、クライアントで表示されるコンテンツが記述されます。

(継承元 Control)
RenderContents(HtmlTextWriter)

コントロールの内容を指定したライターに出力します。 このメソッドは、主にコントロールの開発者によって使用されます。

(継承元 WebControl)
RenderControl(HtmlTextWriter)

指定の HtmlTextWriter オブジェクトにサーバー コントロールの内容を出力し、トレースが有効である場合はコントロールに関するトレース情報を保存します。

(継承元 Control)
RenderControl(HtmlTextWriter, ControlAdapter)

指定した ControlAdapter オブジェクトを使用して、指定した HtmlTextWriter オブジェクトにサーバー コントロールの内容を出力します。

(継承元 Control)
RenderEndTag(HtmlTextWriter)

コントロールの HTML 終了タグを指定したライターに表示します。 このメソッドは、主にコントロールの開発者によって使用されます。

(継承元 WebControl)
ResolveAdapter()

指定したコントロールを表示するコントロール アダプターを取得します。

(継承元 Control)
ResolveClientUrl(String)

ブラウザーで使用できる URL を取得します。

(継承元 Control)
ResolveUrl(String)

要求側クライアントで使用できる URL に変換します。

(継承元 Control)
SaveAs(String)

アップロードしたファイルの内容を Web サーバー上の指定したパスに保存します。

SaveControlState()

ページがサーバーにポスト バックされた時間以降に発生したすべてのサーバー コントロール状態の変化を保存します。

(継承元 Control)
SaveViewState()

TrackViewState() メソッドが呼び出された後に変更された状態を保存します。

(継承元 WebControl)
SetDesignModeState(IDictionary)

コントロールのデザイン時データを設定します。

(継承元 Control)
SetRenderMethodDelegate(RenderMethod)

サーバー コントロールとその内容を親コントロールに表示するイベント ハンドラー デリゲートを割り当てます。

(継承元 Control)
SetTraceData(Object, Object)

トレース データ キーとトレース データ値を使用して、レンダリング データのデザイン時トレースのトレース データを設定します。

(継承元 Control)
SetTraceData(Object, Object, Object)

トレースされたオブジェクト、トレース データ キー、およびトレース データ値を使用して、レンダリング データのデザイン時トレースのトレース データを設定します。

(継承元 Control)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)
TrackViewState()

コントロールでそのビュー ステートの変化を追跡して、その変化をオブジェクトの ViewState プロパティに保存できるようにします。

(継承元 WebControl)

イベント

DataBinding

サーバー コントロールがデータ ソースに連結すると発生します。

(継承元 Control)
Disposed

サーバー コントロールがメモリから解放されると発生します。これは、ASP.NET ページが要求されている場合のサーバー コントロールの有効期間における最終段階です。

(継承元 Control)
Init

サーバー コントロールが初期化されると発生します。これは、サーバー コントロールの有効期間における最初の手順です。

(継承元 Control)
Load

サーバー コントロールが Page オブジェクトに読み込まれると発生します。

(継承元 Control)
PreRender

Control オブジェクトの読み込み後、表示を開始する前に発生します。

(継承元 Control)
Unload

サーバー コントロールがメモリからアンロードされると発生します。

(継承元 Control)

明示的なインターフェイスの実装

IAttributeAccessor.GetAttribute(String)

指定された名前の Web コントロールの属性を取得します。

(継承元 WebControl)
IAttributeAccessor.SetAttribute(String, String)

Web コントロールの属性を指定された名前と値に設定します。

(継承元 WebControl)
IControlBuilderAccessor.ControlBuilder

このメンバーの詳細については、「ControlBuilder」をご覧ください。

(継承元 Control)
IControlDesignerAccessor.GetDesignModeState()

このメンバーの詳細については、「GetDesignModeState()」をご覧ください。

(継承元 Control)
IControlDesignerAccessor.SetDesignModeState(IDictionary)

このメンバーの詳細については、「SetDesignModeState(IDictionary)」をご覧ください。

(継承元 Control)
IControlDesignerAccessor.SetOwnerControl(Control)

このメンバーの詳細については、「SetOwnerControl(Control)」をご覧ください。

(継承元 Control)
IControlDesignerAccessor.UserData

このメンバーの詳細については、「UserData」をご覧ください。

(継承元 Control)
IDataBindingsAccessor.DataBindings

このメンバーの詳細については、「DataBindings」をご覧ください。

(継承元 Control)
IDataBindingsAccessor.HasDataBindings

このメンバーの詳細については、「HasDataBindings」をご覧ください。

(継承元 Control)
IExpressionsAccessor.Expressions

このメンバーの詳細については、「Expressions」をご覧ください。

(継承元 Control)
IExpressionsAccessor.HasExpressions

このメンバーの詳細については、「HasExpressions」をご覧ください。

(継承元 Control)
IParserAccessor.AddParsedSubObject(Object)

このメンバーの詳細については、「AddParsedSubObject(Object)」をご覧ください。

(継承元 Control)

拡張メソッド

FindDataSourceControl(Control)

指定されたコントロールのデータ コントロールに関連付けられているデータ ソースを返します。

FindFieldTemplate(Control, String)

指定されたコントロールの名前付けコンテナー内にある、指定された列のフィールド テンプレートを返します。

FindMetaTable(Control)

格納しているデータ コントロールのメタテーブル オブジェクトを返します。

適用対象

こちらもご覧ください