Watch TextBox, CheckBox and radiobutton auto post back action (C#) : TextBox « Asp Control « ASP.Net

Home
ASP.Net
1.ADO.net Database
2.Ajax
3.Asp Control
4.Collections
5.Components
6.Data Binding
7.Development
8.File Directory
9.HTML Control
10.Language Basics
11.Login Security
12.Mobile Control
13.Network
14.Page
15.Request
16.Response
17.Server
18.Session Cookie
19.Sitemap
20.Theme Style
21.User Control and Master Page
22.Validation by Control
23.Validation by Function
24.WebPart
25.WPF
26.XML
ASP.Net » Asp Control » TextBox 
Watch TextBox, CheckBox and radiobutton auto post back action (C#)

<%@ Page language="c#" src="EventTracker.aspx.cs" AutoEventWireup="false" Inherits="EventTracker" %>
<HTML>
  <body>
    <form id="Form1" method="post" runat="server">
      <P><h3>Controls being monitored for change events:</h3>
        <asp:TextBox id="txt" runat="server" AutoPostBack="True">Text box auto post back</asp:TextBox><BR>
        <BR>
        <asp:CheckBox id="chk" runat="server" AutoPostBack="True"></asp:CheckBox><BR>
        <BR>
        <asp:RadioButton id="opt1" runat="server" GroupName="Sample" AutoPostBack="True"></asp:RadioButton>
        <asp:RadioButton id="opt2" runat="server" GroupName="Sample" AutoPostBack="True"></asp:RadioButton><BR>
        <BR>
        <BR>
        <h3>List of events:</h3>
      <P></P>
      <P>
        <asp:ListBox id="lstEvents" runat="server" Width="355px" Height="256px"></asp:ListBox><BR>
      </P>
    </form>
  </body>
</HTML>

<%--
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

  public class EventTracker : System.Web.UI.Page
  {
    protected System.Web.UI.WebControls.TextBox txt;
    protected System.Web.UI.WebControls.CheckBox chk;
    protected System.Web.UI.WebControls.RadioButton opt1;
    protected System.Web.UI.WebControls.RadioButton opt2;
    protected System.Web.UI.WebControls.ListBox lstEvents;
  
    private void Page_Load(object sender, System.EventArgs e)
    {
       Log("<< Page_Load >>");
    }

    #region Web Form Designer generated code
    override protected void OnInit(EventArgs e)
    {
      //
      // CODEGEN: This call is required by the ASP.NET Web Form Designer.
      //
      InitializeComponent();
      base.OnInit(e);
    }
    
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {    
      this.txt.TextChanged += new System.EventHandler(this.CtrlChanged);
      this.chk.CheckedChanged += new System.EventHandler(this.CtrlChanged);
      this.opt1.CheckedChanged += new System.EventHandler(this.CtrlChanged);
      this.opt2.CheckedChanged += new System.EventHandler(this.CtrlChanged);
      this.Load += new System.EventHandler(this.Page_Load);
      this.PreRender += new System.EventHandler(this.EventTracker_PreRender);

    }
    #endregion

    private void Log(string entry)
    {
      lstEvents.Items.Add(entry);

      // Select the last item to scroll the list so the most recent
      // entries are visible.
      lstEvents.SelectedIndex = lstEvents.Items.Count - 1;
    }

    private void EventTracker_PreRender(object sender, System.EventArgs e)
    {
      // When the Page.UnLoad event occurs it is too late
      // to change the list.
      Log("Page_PreRender");

    }

    private void CtrlChanged(Object sender, EventArgs e)
    {
      // Find the control ID of the sender.
      // This requires converting the Object type into a Control class.
      string ctrlName = ((Control)sender).ID;
      Log(ctrlName + " Changed");
    }

  }

--%>
           
       
Related examples in the same category
1.asp:TextBox: format (VB.net)
2.asp:TextBox: AccessKey (VB.net)
3.asp:TextBox: BorderStyle (VB.net)
4.Single Line asp:TextBox (VB.net)
5.Multiline asp:TextBox (VB.net)
6.MaxLength for asp:textbox (VB.net)
7.TabIndex for asp:textbox (VB.net)
8.asp:textbox: back ground color (VB.net)
9.asp:textbox: wrap (VB.net)
10.BackColor, ForeColor, BorderColor, AccessKey, Columns for asp:textbox (VB.net)
11.Convert value from asp:TextBox to upper case (VB.net)
12.Control asp:TextBox visibility (VB.net)
13.Get Text Box input and check if it is an Odd Number (VB.net)
14.On text changed in asp:TextBox (VB.net)
15.HTML Button, Select and InputBox in code behind (C#)
16.asp: textbox on text changed event (C#)
17.Validate textbox value manually (C#)
18.Is asp:textbox empty (C#)
19.Get value from TextBox (C#)
20.Pre fill the asp textbox control (C#)
21.TextMode: SingleLine, Password and MultiLine
22.Set TextBox focus
23.Triggering an event when a TextBox change occurs (VB)
24.Triggering an event when a TextBox change occurs (C#)
25.Set AutoCompleteType
26.Set MaxLength, Columns
27.Rows, TextMode, Wrap
28.TextMode=Password
29.Create URL from textbox input
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.