Create Server Event via Code

Results 1 to 2 of 2

Thread: Create Server Event via Code

  1. #1
    Join Date
    Dec 1969

    Default Create Server Event via Code

    I need to &#039;associate&#039; a Server Event to a Button via code. I built a Form, a Table, and a Button and I need to get a server event attached to the &#039;click&#039; method for that button see code snippet below...<BR><BR>HtmlForm frmROPtbl = new HtmlForm();<BR>frmROPtbl.Attributes.Add("runat", "server");<BR><BR>Table maintable = new Table();<BR>maintable.Width = Unit.Percentage(100);<BR>TableRow hdrRow = new TableRow();<BR>TableCell hdrCell0 = new TableCell();<BR>TableCell hdrCell1 = new TableCell();<BR>hdrRow.Width = Unit.Percentage(100);<BR>hdrCell0.Width = Unit.Percentage(50);<BR>hdrCell1.Width = Unit.Percentage(50);<BR>Label hdrLabel = new Label();<BR>hdrLabel.ID = "lblCustomerDesc".ToString();<BR>hdrLabel.Widt h = Unit.Pixel(360);<BR><BR>Button btnToExcel = new Button();<BR>btnToExcel.ID = "btnToExcel";<BR>btnToExcel.CssClass ="Button".ToString();<BR>btnToExcel.Text = "To Excel";<BR>btnToExcel.Click += new System.EventHandler(this.btnToExcel_Click);<BR><BR >btnToExcel.Attributes.Add("runat", "server");<BR>//* Attach a Server Event to this Button <BR><BR>hdrCell0.Controls.Add(hdrLabel);<BR>hdrCel l1.Controls.Add(btnToExcel);<BR><BR>hdrRow.Cells.A dd (hdrCell0);<BR>hdrRow.Cells.Add (hdrCell1);<BR>...<BR><BR><BR>Thanks <BR>Andy (<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Create Server Event via Code

    btnToExcel.Click += new System.EventHandler(AddressOf this.btnToExcel_Click);<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts