HtmlForm.Enctype プロパティ
アセンブリ: System.Web (system.web.dll 内)

/** @property */ public String get_Enctype () /** @property */ public void set_Enctype (String value)
エンコードの種類を指定する文字列。既定値は空の文字列 ("") です。ブラウザの既定のコンテンツの種類が使用されていることを示します。

Enctype プロパティを使用して、データをサーバーにポストバックするときにブラウザが使用するエンコードの種類を指定します。
multipart/form-data | |
text/plain |
エンコードの種類の詳細については、W3C (World Wide Web Consortium) の Web サイトを参照してください。

Enctype プロパティを使用して、ブラウザがデータをサーバーに返送する場合に使用するエンコードの種類を指定する方法を次のコード例に示します。
<%@ Page Language="VB" AutoEventWireup="True" %> <script runat="server"> Protected Sub AddButton_Click(ByVal sender As Object, ByVal e As EventArgs) Dim Answer As Integer ' Calculate and display the result. Answer = Convert.ToInt32(Value1.Value) + Convert.ToInt32(Value2.Value) AnswerMessage.InnerHtml = Answer.ToString() End Sub </script> <html> <head> <title>HtmlForm Example</title> </head> <body> <form Method="Post" Enctype="application/x-www-form-urlencoded" runat="server"> <h3> HtmlForm Example </h3> <table> <tr> <td colspan="5"> Enter integer values into the text boxes. <br> Click the Add button to add the two values. <br> Click the Reset button to reset the text boxes. </td> </tr> <tr> <td colspan="5"> </td> </tr> <tr align="center"> <td> <input ID="Value1" Type="Text" Size="2" MaxLength="3" Value="1" runat="server"/> </td> <td> + </td> <td> <input ID="Value2" Type="Text" Size="2" MaxLength="3" Value="1" runat="server"/> </td> <td> = </td> <td> <span ID="AnswerMessage" runat="server"/> </td> </tr> <tr> <td colspan="2"> <asp:RequiredFieldValidator ID="Value1RequiredValidator" ControlToValidate="Value1" ErrorMessage="Please enter a value.<br>" Display="Dynamic" runat="server"/> <asp:CompareValidator ID="Value1MinCompareValidator" ControlToValidate="Value1" Operator="LessThan" Type="Integer" ValueToCompare="100" ErrorMessage="Please enter an integer less than 100.<br>" Display="Dynamic" runat="server"/> <asp:CompareValidator ID="Value1MaxCompareValidator" ControlToValidate="Value1" Operator="GreaterThan" Type="Integer" ValueToCompare="0" ErrorMessage="Please enter an integer greater than 0.<br>" Display="Dynamic" runat="server"/> </td> <td colspan="2"> <asp:RequiredFieldValidator ID="Value2RequiredValidator" ControlToValidate="Value2" ErrorMessage="Please enter a value.<br>" Display="Dynamic" runat="server"/> <asp:CompareValidator ID="Value2MinCompareValidator" ControlToValidate="Value2" Operator="LessThan" Type="Integer" ValueToCompare="100" ErrorMessage="Please enter an integer less than 100.<br>" Display="Dynamic" runat="server"/> <asp:CompareValidator ID="Value2MaxCompareValidator" ControlToValidate="Value2" Operator="GreaterThan" Type="Integer" ValueToCompare="0" ErrorMessage="Please enter an integer greater than 0.<br>" Display="Dynamic" runat="server"/> </td> <td>   </td> </tr> <tr align="center"> <td colspan="4"> <input Type="Submit" Name="AddButton" Value="Add" OnServerClick="AddButton_Click" runat="server"/> <input Type="Reset" Name="AddButton" Value="Reset" runat="server"/> </td> <td> </td> </tr> </table> </form> </body> </html>
<%@ Page Language="C#" AutoEventWireup="True" %> <script runat="server"> protected void AddButton_Click(Object sender, EventArgs e) { int Answer; // Calculate and display the result. Answer = Convert.ToInt32(Value1.Value) + Convert.ToInt32(Value2.Value); AnswerMessage.InnerHtml = Answer.ToString(); } </script> <html> <head> <title>HtmlForm Example</title> </head> <body> <form Method="Post" Enctype="application/x-www-form-urlencoded" runat="server" id="myform"> <h3> HtmlForm Example </h3> <table> <tr> <td colspan="5"> Enter integer values into the text boxes. <br> Click the Add button to add the two values. <br> Click the Reset button to reset the text boxes. </td> </tr> <tr> <td colspan="5"> </td> </tr> <tr align="center"> <td> <input ID="Value1" Type="Text" Size="2" MaxLength="3" Value="1" runat="server"/> </td> <td> + </td> <td> <input ID="Value2" Type="Text" Size="2" MaxLength="3" Value="1" runat="server"/> </td> <td> = </td> <td> <span ID="AnswerMessage" runat="server"/> </td> </tr> <tr> <td colspan="2"> <asp:RequiredFieldValidator ID="Value1RequiredValidator" ControlToValidate="Value1" ErrorMessage="Please enter a value.<br>" Display="Dynamic" runat="server"/> <asp:CompareValidator ID="Value1MinCompareValidator" ControlToValidate="Value1" Operator="LessThan" Type="Integer" ValueToCompare="100" ErrorMessage="Please enter an integer less than 100.<br>" Display="Dynamic" runat="server"/> <asp:CompareValidator ID="Value1MaxCompareValidator" ControlToValidate="Value1" Operator="GreaterThan" Type="Integer" ValueToCompare="0" ErrorMessage="Please enter an integer greater than 0.<br>" Display="Dynamic" runat="server"/> </td> <td colspan="2"> <asp:RequiredFieldValidator ID="Value2RequiredValidator" ControlToValidate="Value2" ErrorMessage="Please enter a value.<br>" Display="Dynamic" runat="server"/> <asp:CompareValidator ID="Value2MinCompareValidator" ControlToValidate="Value2" Operator="LessThan" Type="Integer" ValueToCompare="100" ErrorMessage="Please enter an integer less than 100.<br>" Display="Dynamic" runat="server"/> <asp:CompareValidator ID="Value2MaxCompareValidator" ControlToValidate="Value2" Operator="GreaterThan" Type="Integer" ValueToCompare="0" ErrorMessage="Please enter an integer greater than 0.<br>" Display="Dynamic" runat="server"/> </td> <td>   </td> </tr> <tr align="center"> <td colspan="4"> <input Type="Submit" Name="AddButton" Value="Add" OnServerClick="AddButton_Click" runat="server"/> <input Type="Reset" Name="AddButton" Value="Reset" runat="server"/> </td> <td> </td> </tr> </table> </form> </body> </html>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からHtmlForm.Enctype プロパティを検索する場合は、下記のリンクをクリックしてください。

- HtmlForm.Enctype プロパティのページへのリンク