Question Button onclick event

jim_jim

New member
Joined
Jul 17, 2013
Messages
1
Programming Experience
Beginner
Hi All
Iam a beginner and need help with the below

I'm trying to build a cell within a table . The cell is going to be a button which should open the hyperlink(An email address) .How do i write the onclick event for the button.This particular cell has its own email address that is fetched from the database which upon clicking should open the email address

Below is the code in VB for the cell that i'm building
newCell = New TableCell
newCell.ID = "celRptSelect" & rptRow & "F"
newCell.Style("width") = rowRptSelectHeadF.Style("width")
newCell.CssClass = "TableButton"
newCell.Text = "SME"
newCell.Attributes.Add("onclick", "rpt.SmeEmail")
newCell.Attributes.Add("runat", "server")
newRow.Cells.Add(newCell)rpt.SmeEmail is the data that i'm getting from database and iam not sure how to use it. Please help


Thanks in advance
 
To do this add the control to the table cell. You need to call the Controls.Add method on the cell and add your control.
It would be like this :

Button b = new Button();
b.Text = "Some Button";
b.Click += new EventHandler(b_Click);
cell.Controls.Add(b);

You can write your click event in b_Click function.
 
Back
Top