このコードを見てください:
static int i = 0;
protected void Page_Load(object sender, EventArgs e)
{
HtmlButton myButton;
if (!Page.IsPostBack)
{
myButton = new HtmlButton();
myButton.InnerText = "Button first load";
myButton.ID = i.ToString();
PlaceHolder1.Controls.Add(myButton);
i++;
}
else
{
myButton = new HtmlButton();
myButton.InnerText = "Button postback" + i.ToString();
myButton.ID = i.ToString();
PlaceHolder1.Controls.Add(myButton);
i++;
}
}
期待される:
first load: "Button first load"
first postback: first load + "Button postback1"
second postback: first postback + "Button postback2" ... and so on.
持ってる:
"Button first load"
"Button postback1"
"Button postback2".
なんで?