Kontroller mangler
Jeg er lige faret vild i mine event life-cycles...Jeg har dette kode. Hvordan får jeg OnClick til at udskrive et tal > 0? (line nu udskriver den blot 0, det er somom at den ikke gemmer de data som jeg opretter)
Eksemplet er et simplificeret udsnit af min kode (ASP.NET 1.1)
namespace Test{
public class Demo : Page {
protected System.Web.UI.WebControls.Button but_save;
protected System.Web.UI.WebControls.PlaceHolder plh_table;
private HtmlTable maintable = new HtmlTable();
private void Page_Load(object sender, System.EventArgs e) {
if(!IsPostBack){
CreateTable();
but_save.Text = Language.GetTerm("save", false);
}
}
private void CreateTable(){
maintable.ID = "maintable";
HtmlTableRow row = new HtmlTableRow();
HtmlTableCell cell = new HtmlTableCell();
foreach(string s in TestStrings.Strings){
row = new HtmlTableRow();
row.ID = "row_" + s;
cell.InnerText = s;
row.Cells.Add(cell);
maintable.Rows.Add(row);
}
plh_table.Controls.Add(maintable);
}
#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.but_save.Click += new System.EventHandler(this.but_save_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void but_save_Click(object sender, System.EventArgs e) {
Response.WriteLine(maintable.Rows.Count.ToString());
}
}
}