Just now, Insus. NET has tried to change a piece of code, which is a small function that allows users to dynamically change the webpage background image. When Insus. NET executes the button Click event, it returns a title error.
The Code is as follows:
There was no problem with this code, but now I have added the #6 lines of code, which is a button. When the click event is executed, an exception occurs. The Click Event code is as follows:
How can this problem be solved?
Finally, I found a method on the Internet:
Http://leedumond.com/blog/the-controls-collection-cannot-be-modified-because-the-control-contains-code-blocks/
About ):
As Insus. NET understands, replace "=" with "#" And Bind data to the Page_load event.
In the Page_load event:
OK.
However, Insus. NET wants to solve this problem using its own method.
Remove the style of the webpage head node:
Go to the Page. aspx. cs's Page_Load to remove the sentence: Page. Header. DataBind ();
And add a method protected override void OnInit (EventArgs e)
The Click event of the button has not changed:
# The difference between image a and Image B is that the image name is different. Refactoring:
Take a look at the dynamic change page background image: