I know its been asked before but I cannot get the event to fire even if Im creating the buttons and events each OnInit. Im doing a Sharepoint 2010 web part and fill a radiobuttonlist with values and add a submit button to the web part each time OnInit gets called. The Page_Load method is empty. I also tried putting the paintQnA call in an overridden CreateChildControls with the same result.
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
...//Get data needed to create gui
paintQnA(dr, dt, currentRow);
}
void paintQnA(DataRow dr, DataTable dt, int currentRow)
{
Panel p = new Panel();
p.ID = currentRow.ToString();
Label lbl= new Label();
lbl.Text = dr["Title"].ToString();
RadioButtonList rbl = new RadioButtonList();
rbl.ID = currentRow.ToString() + "1";
HtmlButton submitBtn = new HtmlButton();
submitBtn.ID = currentRow.ToString();
submitBtn.InnerText = "Click";
submitBtn.ServerClick += new EventHandler(submitBtn_Click);
...//fill the radiobuttonlist with data
this.Controls.Add(p);
p.Controls.Add(lbl);
p.Controls.Add(rbl);
p.Controls.Add(submitBtn);
UpdatePanel1.ContentTemplateContainer.Controls.Add(p);
}
void submitBtn_Click(object sender, EventArgs e)
{
...//Should display another dynamically created panel but is never reached.
}
HtmlButtoninstead ofButtonobject?submitBtn.Clickinstead ofsubmitBtn.ServerClick?