LinkButton linkButtonDelete = new LinkButton();
linkButtonDelete.CommandName = "Delete";
linkButtonDelete.Command += new CommandEventHandler(this.LinkButton_Command);private void LinkButton_Command(object sender, System.Web.UI.WebControls.CommandEventArgs e)
{
....
}

解决方案 »

  1.   

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
            'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
            '不要使用代码编辑器修改它。
            InitializeComponent()
            Dim l As LinkButton = MenuFirst1.LBtSbzz
            Dim l1 As LinkButton = MenuSecond1.LBtSbzz
            Dim l2 As LinkButton = MenuSecond1.LBtNameSz
            AddHandler l.Click, AddressOf MenuFirstLBtSbzz_click
            AddHandler l1.Click, AddressOf MenuSecondLBtSbzz_click
            AddHandler l2.Click, AddressOf MenuSecondLBtNameSz_click
        End Sub
    然后]
     Private Sub MenuFirstLBtSbzz_click(ByVal source As Object, ByVal e As System.EventArgs)
    .........
    事件。
      

  2.   

    MenuFirst1.LBtSbzz是什么意思
    ===〉
    用户控件Public MustInherit Class MenuFirst
        Inherits System.Web.UI.UserControl
        Public WithEvents LBtSbzz As System.Web.UI.WebControls.LinkButton
      

  3.   

    把自定义控件的方法声明为PUBLIC,在页面中通过自定义控件的对象调用该方法
      

  4.   

    在webform1.aspx中,
    protected System.Web.UI.WebControls.Button Button1;
    protected u1 U11;

    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)
    {
      this.U11.Button1_Click(sender,e);
    }
    在用户控件中u1.ascx中。
    public class u1 : System.Web.UI.UserControl
    {
    public 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 public void Button1_Click(object sender, System.EventArgs e)
    {
    Response.Write ("<script language=javascript>alert('aaa')</script>");
    }
    }
      

  5.   

    1. CSDNCCS.vb (compiled to CSDNCCS.dll):Imports System.ComponentModel
    Imports System.Web.UI
    Imports System.Web.UI.WebControls<DefaultProperty("Text"), ToolboxData("<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>")> Public Class WebCustomControl1
        Inherits System.Web.UI.WebControls.WebControl
        Implements INamingContainer    Public Event MyClick As EventHandler    Protected Overrides Sub CreateChildControls()
            Dim btn As New Button()
            btn.Text = "Click me"
            AddHandler btn.Click, AddressOf Btn_Click
            Controls.Add(btn)
        End Sub    Private Sub Btn_Click(ByVal sender As Object, ByVal e As EventArgs)
            RaiseEvent MyClick(sender, e)
        End SubEnd Class2. testpage.aspx:<%@ Register TagPrefix="cc1" Namespace="CSDNCCS" Assembly="CSDNCCS" %>
    <script language="vb" runat="server">
    Sub TestClick(ByVal sender as Object, e as EventArgs)
      Response.Write("Click Me Button is clicked at " + DateTime.Now)
    End Sub
    </script>
    <form id="Form1" method="post" runat="server">
     <cc1:WebCustomControl1 id="WebCustomControl11" runat="server" Width="138px" Height="37px" OnMyClick="TestClick"></cc1:WebCustomControl1>
    </form>