HtmlInputRadioButton.OnPreRender Method

Raises the PreRender event and registers the HtmlInputRadioButton control as one that requires postback handling.

Namespace: System.Web.UI.HtmlControls
Assembly: System.Web (in system.web.dll)

protected public:
virtual void OnPreRender (
	EventArgs^ e
) override
protected void OnPreRender (
	EventArgs e
)
protected internal override function OnPreRender (
	e : EventArgs
)

Parameters

e

A System.EventArgs that contains the event data.

The OnPreRender method is called just prior to rendering the HtmlInputRadioButton control.

The OnPreRender method is used primarily by control developers extending the functionality of the HtmlInputRadioButton control.

The following code example demonstrates how to override the OnPreRender method so that it adds a Title attribute in a custom HtmlInputRadioButton server control.

No code example is currently available or this language may not be supported.
<%@ Page Language="VJ#" AutoEventWireup="True" %>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.JSL.Controls" Assembly="Samples.AspNet.JSL" %>
<HTML>
  <HEAD><title>Custom HtmlInputRadioButton - OnPreRender - VJ# Example</title>
    <script runat="server">
    void Page_Load(Object sender, EventArgs e) 
    {
        Div1.set_InnerHtml("");
    } //Page_Load

    void HtmlInputRadioButtonGroup1_ServerChange(Object sender,
        System.EventArgs e)
    {
        // Diplay the value of the selected HtmlInputRadioButton control.
        System.Web.UI.HtmlControls.HtmlInputRadioButton 
            htmlInputRadioButtonGroup1 = (System.Web.UI.HtmlControls.
            HtmlInputRadioButton)sender;
        Div1.set_InnerHtml("You change your selection to: "
            + htmlInputRadioButtonGroup1.get_Value());
    } //HtmlInputRadioButtonGroup1_ServerChange
    </script>
  </HEAD>
  <body>
    <form id="Form1" method="post" runat="server">
      <h3>Custom HtmlInputRadioButton - OnPreRender - VJ# Example</h3>

      <aspSample:CustomHtmlInputRadioButtonOnPreRender 
        id="HtmlInputRadioButton1" 
        name="HtmlInputRadioButtonGroup1" 
        runat="server" 
        type="radio" checked
        onserverchange="HtmlInputRadioButtonGroup1_ServerChange" 
        value="HtmlInputRadioButton1">HtmlInputRadioButton1
      </aspSample:CustomHtmlInputRadioButtonOnPreRender>
      <br>

      <aspSample:CustomHtmlInputRadioButtonOnPreRender 
        id="HtmlInputRadioButton2" 
        name="HtmlInputRadioButtonGroup1" 
        runat="server" 
        type="radio" 
        onserverchange="HtmlInputRadioButtonGroup1_ServerChange" 
        value="HtmlInputRadioButton2">HtmlInputRadioButton2
      </aspSample:CustomHtmlInputRadioButtonOnPreRender>

      <p>
        <input type="submit" value="Submit" id="Submit1" name="Submit1" runat="server">
      </p>
      
      <DIV 
        id="Div1" 
        runat="server" 
        style="DISPLAY: inline; WIDTH: 256px; HEIGHT: 15px" 
        ms_positioning="FlowLayout" />
    </form>
  </body>
</HTML>

No code example is currently available or this language may not be supported.
package Samples.AspNet.JSL.Controls;

public class CustomHtmlInputRadioButtonOnPreRender
    extends System.Web.UI.HtmlControls.HtmlInputRadioButton
{
    protected void OnPreRender(System.EventArgs e)
    {
        // Run the OnPreRender method on the base class.
        super.OnPreRender(e);
        // Add a Title attribute.
        this.get_Attributes().Add("title", "Option " + this.get_Value());
    } //OnPreRender
} //CustomHtmlInputRadioButtonOnPreRender

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

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show: