We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Swapping images in a rendered html document

I am interested in changing an image in an HTMLUIControl after the page has been rendered. The following statement does not appear to work: this.image1.Attributes["src"].Value = "..\\..\\btnStep3d0.bmp"; It gives me this error: “Object reference not set to an instance of an object.” I made sure that I had instanciated image1. The following code was executed before trying to add an image to the document. public void htmluiControlLoadFinished() { WireElements(); } private void WireElements() { try { htmlelements = htmlCtrl.Document.GetElementsByUserIdHash(); this.image1 = htmlelements["Image1"] as BaseElement; ... Here is the HTML Code I used (abbreviated):
I also tried loading the document without attempting to change the image. It worked fine. It loaded images directly hard coded into the html document. I just cannot change out the image after it is loaded. I also wondered whether not having quotes on the statement was making a difference. So, I tried the following statement: this.image1.Attributes["src"].Value = "\"..\\..\\ImageName.bmp\""; I got the same error as above. Can someone see something in my code that is incorrect? Any help or advice would be appreciated.

2 Replies

NC Neil Conway February 16, 2006 06:13 PM UTC

I forgot that the forum would try to render my piece of html code. Here it is again without brackets: td IMG alt="" src="" id="Image1" /td


NC Neil Conway February 17, 2006 01:05 PM UTC

I found the error. The wiring event was not firing. My apologies for the false alarm. I thought that there was a problem with how I had entered the filepath of the image. That turned out not to be the case.

Loader.
Live Chat Icon For mobile
Up arrow icon