Hello everybody!
I want to create an image with every click of some button.
I used following code:
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button butAdd;
System.Web.UI.WebControls.Image[] myImage;// = new System.Web.UI.WebControls.Image();
int yCount = 0;
int iCount = 0;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
yCount = 150;
iCount = 0;
}
#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.butAdd.Click += new System.EventHandler(this.butAdd_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void butAdd_Click(object sender, System.EventArgs e)
{
//
//System.Web.UI.WebControls.Image myImage = new System.Web.UI.WebControls.Image();
myImage[iCount].Style["Left"] = "150";
myImage[iCount].Style["Top"] = yCount.ToString();
yCount += 20;
myImage[iCount].Style["Z-INDEX"] = "112";
myImage[iCount].Style["POSITION"] = "absolute";
Page.Controls.Add(myImage[iCount]);
iCount++;
}
}
But it doesn't work. No mistakes, but none image appear after click.
Where is a mistake here, or may be i just do it wrong?
Will be very thankful for any kind of help!
Best regards,
Alexander
I want to create an image with every click of some button.
I used following code:
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button butAdd;
System.Web.UI.WebControls.Image[] myImage;// = new System.Web.UI.WebControls.Image();
int yCount = 0;
int iCount = 0;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
yCount = 150;
iCount = 0;
}
#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.butAdd.Click += new System.EventHandler(this.butAdd_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void butAdd_Click(object sender, System.EventArgs e)
{
//
//System.Web.UI.WebControls.Image myImage = new System.Web.UI.WebControls.Image();
myImage[iCount].Style["Left"] = "150";
myImage[iCount].Style["Top"] = yCount.ToString();
yCount += 20;
myImage[iCount].Style["Z-INDEX"] = "112";
myImage[iCount].Style["POSITION"] = "absolute";
Page.Controls.Add(myImage[iCount]);
iCount++;
}
}
But it doesn't work. No mistakes, but none image appear after click.
Where is a mistake here, or may be i just do it wrong?
Will be very thankful for any kind of help!
Best regards,
Alexander