how to fire a event to my dynamic created textboxes?

Discussion in 'ASP .Net Building Controls' started by Satish, Jul 29, 2003.

  1. Satish

    Satish Guest

    hi,
    how to fire a event to my dynamic created textboxes?...say all buttons
    will inturn call a same method...say sayhi()?
    here is my code...
    Thanks in advance.
    -Satish



    ASPX
    ~~~~

    <%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
    AutoEventWireup="false" Inherits="dyna.WebForm1" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>WebForm1</title>
    <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
    <meta name="CODE_LANGUAGE" Content="C#">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema"
    content="http://schemas.microsoft.com/intellisense/ie5">
    </HEAD>
    <body MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
    <asp:Label id="Label1" style="Z-INDEX: 101; LEFT: 39px; POSITION:
    absolute; TOP: 61px" runat="server">enter no of textbox to
    create</asp:Label>
    <asp:TextBox id="TextBox1" style="Z-INDEX: 102; LEFT: 46px;
    POSITION: absolute; TOP: 91px" runat="server"></asp:TextBox>
    <asp:placeHolder id="PlaceHolder1"
    runat="server"></asp:placeHolder>
    <asp:Button id="Button1" style="Z-INDEX: 104; LEFT: 225px;
    POSITION: absolute; TOP: 94px" runat="server"
    Text="Create"></asp:Button>
    </form>
    </body>
    </HTML>


    Behind the code
    ~~~~~~~~~~~~~~~
    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;

    namespace dyna
    {
    /// <summary>
    /// Summary description for WebForm1.
    /// </summary>
    public class WebForm1 : System.Web.UI.Page
    {
    protected System.Web.UI.WebControls.Label Label1;
    protected System.Web.UI.WebControls.TextBox TextBox1;
    protected System.Web.UI.WebControls.PlaceHolder PlaceHolder1;
    protected System.Web.UI.WebControls.RangeValidator RangeValidator1;
    protected System.Web.UI.WebControls.Button Button1;

    private void Page_Load(object sender, System.EventArgs e)
    {
    // Put user code to initialize the page here


    }

    #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.Button1.Click += new System.EventHandler(this.Button1_Click);
    this.Load += new System.EventHandler(this.Page_Load);

    }
    #endregion

    private void Button1_Click(object sender, System.EventArgs e)
    {
    int i;
    int count=Int32.Parse(TextBox1.Text);
    for(i=0;i<count;i++)
    {
    Button str = new Button();
    str.ID = "box"+i.ToString() ;
    //this.FindControl("Form1").Controls.Add(str);
    PlaceHolder1.Controls.Add(str);
    }
    }

    }
    }
     
    Satish, Jul 29, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Forconi Boris via .NET 247

    TextBoxes created dynamically : How to store data?

    Forconi Boris via .NET 247, Jun 17, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    388
    Trevor Benedict R
    Jun 18, 2004
  2. SD
    Replies:
    3
    Views:
    474
    =?Utf-8?B?S2V6emE=?=
    Jun 23, 2005
  3. Amelyan
    Replies:
    2
    Views:
    694
    Amelyan
    Nov 5, 2005
  4. Jean-Pierre Fouche

    Dynamic Datagrid with TextBoxes Textchanged events wont fire

    Jean-Pierre Fouche, Jul 28, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    207
    Cristian Suazo
    Jul 29, 2003
  5. Biguana
    Replies:
    3
    Views:
    511
Loading...

Share This Page