HtmlInputText.OnPreRender メソッド
アセンブリ: System.Web (system.web.dll 内)

Dim e As EventArgs Me.OnPreRender(e)

OnPreRender メソッドは、HtmlInputText コントロールをレンダリングする直前に呼び出されます。OnPreRender メソッドは、主に、コントロール開発者が HtmlInputText コントロールの機能を拡張する際に使用します。

OnPreRender メソッドをオーバーライドして、カスタムの HtmlInputText サーバー コントロールの MaxLength プロパティに文字数として 30 を設定する方法を次のコード例に示します。
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB" %> <%@ Page Language="VB" AutoEventWireup="True" %> <script runat="server"> Sub Page_Load(sender As Object, e As EventArgs) If Not Page.IsPostBack Then HtmlInputText1.Value = "Hello HtmlInputText World." End If End Sub Sub HtmlInputText1_ServerChange(sender As Object, e As System.EventArgs) Dim htmlInputText1 As System.Web.UI.HtmlControls.HtmlInputText = CType(sender, System.Web.UI.HtmlControls.HtmlInputText) Div1.InnerHtml = "Change the preceding text to:<br>" & htmlInputText1.Value End Sub </script> <html> <head> <title>Custom HtmlInputText OnPreRender Example</title> </head> <body> <form id="Form1" method="post" runat="server"> <h3>Custom HtmlInputText OnPreRender Example</h3> <p>Make a change to the text, and then press the ENTER.<br> <aspSample:CustomHtmlInputTextOnPreRender id="HtmlInputText1" name="HtmlInputText1" runat="server" type="text" size="45" style="WIDTH: 305px; HEIGHT: 22px" onserverchange="HtmlInputText1_ServerChange"> </p> <p> <DIV id="Div1" runat="server" style="DISPLAY: inline; WIDTH: 256px; HEIGHT: 15px" ms_positioning="FlowLayout" /> </p> </form> </body> </html>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS" %> <%@ Page Language="C#" AutoEventWireup="True" %> <script runat="server"> void Page_Load(Object sender, EventArgs e) { if (!Page.IsPostBack) { HtmlInputText1.Value = "Hello HtmlInputText World."; } } void HtmlInputText1_ServerChange(object sender, System.EventArgs e) { // Diplay the value of the selected HtmlInputText control. System.Web.UI.HtmlControls.HtmlInputText htmlInputText1 = (System.Web.UI.HtmlControls.HtmlInputText) sender; Div1.InnerHtml = "Change the preceding text to:<br>" + htmlInputText1.Value; } </script> <html> <head> <title>Custom HtmlInputText OnPreRender Example</title> </head> <body> <form id="Form1" method="post" runat="server"> <h3>Custom HtmlInputText OnPreRender Example</h3> <p>Make a change to the text, and then press the ENTER.<br> <aspSample:CustomHtmlInputTextOnPreRender id="HtmlInputText1" name="HtmlInputText1" runat="server" type="text" size="45" style="WIDTH: 305px; HEIGHT: 22px" onserverchange="HtmlInputText1_ServerChange"> </p> <p> <DIV id="Div1" runat="server" style="DISPLAY: inline; WIDTH: 256px; HEIGHT: 15px" ms_positioning="FlowLayout" /> </p> </form> </body> </html>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.JSL.Controls" Assembly="Samples.AspNet.JSL" %> <%@ Page Language="VJ#" AutoEventWireup="True" %> <HTML> <HEAD> <title>Custom HtmlInputText - OnPreRender - VJ# Example</title> <script runat="server"> void Page_Load(Object sender, EventArgs e) { if (!get_Page().get_IsPostBack()) { HtmlInputText1.set_Value("Hello HtmlInputText World."); } } //Page_Load void HtmlInputText1_ServerChange(Object sender, System.EventArgs e) { // Diplay the value of the selected HtmlInputText control. System.Web.UI.HtmlControls.HtmlInputText htmlInputText1 = (System.Web.UI.HtmlControls.HtmlInputText)sender; Div1.set_InnerHtml("You change the above text to:<br>" + htmlInputText1.get_Value()); } //HtmlInputText1_ServerChange </script> </HEAD> <body> <form id="Form1" method="post" runat="server"> <h3>Custom HtmlInputText - OnPreRender - VJ# Example</h3> <p>Make a change to the text, then press the Enter key.<br> <aspSample:CustomHtmlInputTextOnPreRender id="HtmlInputText1" name="HtmlInputText1" runat="server" type="text" size="45" style="WIDTH: 305px; HEIGHT: 22px" onserverchange="HtmlInputText1_ServerChange"> </p> <p> <DIV id="Div1" runat="server" style="DISPLAY: inline; WIDTH: 256px; HEIGHT: 15px" ms_positioning="FlowLayout" /> </p> </form> </body> </HTML>
<AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _ Public NotInheritable Class CustomHtmlInputTextOnPreRender Inherits System.Web.UI.HtmlControls.HtmlInputText Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs) ' Call the base class's OnPreRender method. MyBase.OnPreRender(e) ' Set the HtmlInputText object's MaxLength property to 30 characters. Me.MaxLength = 30 End Sub End Class
using System.Web; using System.Security.Permissions; namespace Samples.AspNet.CS.Controls { [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)] public sealed class CustomHtmlInputTextOnPreRender : System.Web.UI.HtmlControls.HtmlInputText { protected override void OnPreRender(System.EventArgs e) { // Call the base class's OnPreRender method. base.OnPreRender(e); // Set the HtmlInputText object's MaxLength property to 30 characters. this.MaxLength = 30; } } }
package Samples.AspNet.JSL.Controls; public class CustomHtmlInputTextOnPreRender extends System.Web.UI.HtmlControls.HtmlInputText { protected void OnPreRender(System.EventArgs e) { // Call the base's OnPreRender method. super.OnPreRender(e); // Set the HtmlInputText's MaxLength to 30 chars. this.set_MaxLength(30); } //OnPreRender } //CustomHtmlInputTextOnPreRender

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に収録されているすべての辞書からHtmlInputText.OnPreRender メソッドを検索する場合は、下記のリンクをクリックしてください。

- HtmlInputText.OnPreRender メソッドのページへのリンク