Reputation: 475
Im seeking your help again! I'm new in c#,so please don't be wondering why I'm asking such things. :)
I'm facing a weird issue ritenow. I have this code:
private void pictureBox1_Click(object sender, EventArgs e)
{
pictureBox1.ImageLocation = "http://www.jmorganmarketing.com/wp-content/uploads/2010/11/image4.jpg";
}
The problem is that the image is showing(loading) only when I click inside of the picturebox.
Can someone give me an example on how to load the image without clicking in it?
THANKS in advance for any replay!
Upvotes: 1
Views: 6710
Reputation: 2008
Simply register a Load EventHandler and set the URL of your picturebox there.
Upvotes: 1
Reputation: 4657
You wrote the code inside Click
event of picture box. It means when it clicked do the job. you should put pictureBox1.ImageLocation = "http://www.jmorganmarketing.com/wp-content/uploads/2010/11/image4.jpg";
whenever you want to set the image.
Upvotes: 2
Reputation: 46879
Put the code in your page_load event, not the picturebox1_click event.
protected void Page_Load(object sender, EventArgs e) {
pictureBox1.ImageLocation = "http://www.jmorganmarketing.com/wp-content/uploads/2010/11/image4.jpg"
}
Upvotes: 4