在后台页面定义就行了, 在前台页面实例化的你可以没有注册这个click事件

解决方案 »

  1.   

    1. 对象 对象名 = new 对象;2.你要先定义button的click事件this.button1.Click += new System.EventHandler(this.button1_Click);
      

  2.   

    下面是生成的代码, 但是并看不到有Button1的实例化动作呀: #region Web 窗体设计器生成的代码
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {    
    this.Button1.Click += new System.EventHandler(this.Button1_Click);
    this.Load += new System.EventHandler(this.Page_Load); }
    #endregion
      

  3.   

    写代码的地方右键,然后outlining-->toggle all outlining可以将代码全部展开并看到
    public class Form1 : System.Windows.Forms.Form
    {
    private System.Windows.Forms.Button button2;
    public System.Windows.Forms.TextBox textBox1;
    public Form1()
    {
    InitializeComponent();}
    private void InitializeComponent()
    {
    this.button2.Location = new System.Drawing.Point(336, 200);
    this.button2.Name = "button2";
    this.button2.Size = new System.Drawing.Size(144, 56);
    this.button2.TabIndex = 1;
    this.button2.Text = "button2";
    this.button2.Click += new System.EventHandler(this.button2_Click);
    }
    }
      

  4.   

    你有这句:
    this.Button1.Click += new System.EventHandler(this.Button1_Click);
    再加上你的
    private void Button1_Click(object sender, System.EventArgs e)
    {
      Button1.Text = "ABC";
    }
    不会有问题的
      

  5.   

    没有问题的。
    ----------------------------
    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 WebApplication4
    {
    /// <summary>
    /// WebForm1 的摘要说明。
    /// </summary>
    public class WebForm1 : System.Web.UI.Page
    {
    protected System.Web.UI.WebControls.Button Button1;

    private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面
    } #region Web Form Designer generated code
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </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)
    {
    Button1.Text="abc";
    }
    }
    }
      

  6.   

    按照楼上兄弟的方法,的确可以的,我试过了!!!但 protected System.Web.UI.WebControls.Button Button1;
    没有必要这么长吆!!在开头的命名空间中已经引入了呀!!嘿嘿!!
      

  7.   

    1.
    你在VS.NET中创建一个WebForm1.aspx的文件,VS.NET会自动创建一个WebForm1.aspx.cs文件,你在WebForm1.aspx中放一个Button1,VS.NET会自动在WebForm1.aspx.cs中放一个protected的Button1...
      

  8.   

    呵呵,第一个问题我就不说了,大家都说了。
    关于第二个问题,我认为楼主有必要参考一下代理委托的概念,或者确定webform是否是当前你所点击的这个button的父容器。
      

  9.   

    双击form的按纽,在函数体中添加
            Button1.Text = "ABC";   //Button1为控件名