Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with creation image dynamicaly!

Status
Not open for further replies.

passs

Programmer
Dec 29, 2003
170
RU
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[&quot;Left&quot;] = &quot;150&quot;;
myImage[iCount].Style[&quot;Top&quot;] = yCount.ToString();
yCount += 20;
myImage[iCount].Style[&quot;Z-INDEX&quot;] = &quot;112&quot;;
myImage[iCount].Style[&quot;POSITION&quot;] = &quot;absolute&quot;;
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top