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

Dim e As EventArgs Me.OnPreRender(e)


OnPreRender メソッドをオーバーライドして、HtmlInputButton カスタム コントロールを常に太字で表示する方法を次のコード例に示します。
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB" %> <%@ Page Language="VB" AutoEventWireup="True" %> <HTML> <HEAD> <title>Custom HtmlInputButton - OnPreRender - Visual Basic Example</title> <script runat="server"> Sub Page_Load(sender As Object, e As EventArgs) HtmlInputButton1.Attributes.Add("onclick", "alert('Hello client-side world.');") End Sub Sub HtmlInputButton1_ServerClick(sender As Object, e As EventArgs) Div1.InnerHtml = "Hello server-side world." End Sub </script> </HEAD> <body> <form id="Form1" method="post" runat="server"> <h3>Custom HtmlInputButton - OnPreRender - Visual Basic Example</h3> <aspSample:CustomHtmlInputButtonOnPreRender id="HtmlInputButton1" runat="server" type="button" onserverclick="HtmlInputButton1_ServerClick" value="Html Input Button" name="HtmlInputButton1"> <DIV id="Div1" runat="server" style="DISPLAY: inline; WIDTH: 256px; HEIGHT: 15px" ms_positioning="FlowLayout" /> </form> </body> </HTML>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS" %> <%@ Page Language="C#" AutoEventWireup="True" %> <HTML> <HEAD> <title>Custom HtmlInputButton - OnPreRender - C# Example</title> <script runat="server"> void Page_Load(Object sender, EventArgs e) { HtmlInputButton1.Attributes.Add("onclick","alert('Hello client-side world.');"); } void HtmlInputButton1_ServerClick(Object sender, EventArgs e) { Div1.InnerHtml = "Hello server-side world."; } </script> </HEAD> <body> <form id="Form1" method="post" runat="server"> <h3>Custom HtmlInputButton - OnPreRender - C# Example</h3> <aspSample:CustomHtmlInputButtonOnPreRender id="HtmlInputButton1" runat="server" type="button" onserverclick="HtmlInputButton1_ServerClick" value="Html Input Button" name="HtmlInputButton1"> <DIV id="Div1" runat="server" style="DISPLAY: inline; WIDTH: 256px; HEIGHT: 15px" ms_positioning="FlowLayout" /> </form> </body> </HTML>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.JSL.Controls" Assembly="Samples.AspNet.JSL" %> <%@ Page Language="VJ#" AutoEventWireup="True" %> <HTML> <HEAD> <title>Custom HtmlInputButton - OnPreRender - VJ# Example</title> <script runat="server"> void Page_Load(Object sender, EventArgs e) { HtmlInputButton1.get_Attributes().Add("onclick", "alert('Hello client-side world.');"); } //Page_Load void HtmlInputButton1_ServerClick(Object sender, EventArgs e) { Div1.set_InnerHtml("Hello server-side world."); } //HtmlInputButton1_ServerClick </script> </HEAD> <body> <form id="Form1" method="post" runat="server"> <h3>Custom HtmlInputButton - OnPreRender - VJ# Example</h3> <aspSample:CustomHtmlInputButtonOnPreRender id="HtmlInputButton1" runat="server" type="button" onserverclick="HtmlInputButton1_ServerClick" value="Html Input Button" name="HtmlInputButton1"> <DIV id="Div1" runat="server" style="DISPLAY: inline; WIDTH: 256px; HEIGHT: 15px" ms_positioning="FlowLayout" /> </form> </body> </HTML>
Imports System.Web Imports System.Security.Permissions Namespace Samples.AspNet.VB.Controls <AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _ Public NotInheritable Class CustomHtmlInputButtonOnPreRender Inherits System.Web.UI.HtmlControls.HtmlInputButton Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs) ' Call the base class's OnPreRender method. MyBase.OnPreRender(e) ' Always display the HtmlInputButton with bold text. Me.Style.Add("font-weight", "bold") End Sub End Class End Namespace
using System.Web; using System.Security.Permissions; namespace Samples.AspNet.CS.Controls { [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)] public sealed class CustomHtmlInputButtonOnPreRender : System.Web.UI.HtmlControls.HtmlInputButton { protected override void OnPreRender(System.EventArgs e) { // Call the base class's OnPreRender method. base.OnPreRender(e); // Always display the HtmlInputButton with bold text. this.Style.Add("font-weight", "bold"); } } }
package Samples.AspNet.JSL.Controls; public class CustomHtmlInputButtonOnPreRender extends System.Web.UI.HtmlControls.HtmlInputButton { protected void OnPreRender(System.EventArgs e) { // Call the base OnPreRender method. super.OnPreRender(e); // Always display the HtmlButton with bold text. this.get_Style().Add("font-weight", "bold"); } //OnPreRender } //CustomHtmlInputButtonOnPreRender

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


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