When I got up this morning, I found some comments on skype. The situation is as follows. However, Insus. NET should first thank the netizens for testing.
Http://www.cnblogs.com/insus/p/3193619.html if you have read this blog. In addition, it is not displayed normally during running. For example:
"Are you sure you can run it correctly? Why does it look like this when I test it, because every step is done. "
OH, during the demonstration by Insus. NET, this exception exists, but it is not seen to be very serious, because it is usually seen more, just a slight adjustment, you can. When this exception occurs, the Page_Load event of the user control is removed, and an IsPostBack is taken away.
Remove it, and the program can run !!!
Because of PostBack, an object is not saved after PostBack. If we need the Page_Load event, add the judgment. What should I do if I add IsPostback TO THE Page_Load event of the webpage or the Page_Load event of the user control?
Okay, let's first change the program and add the IsPostBack judgment to both the webpage and user control.
After adding and determining, the program runs. After PostBack, the dynamic addition part will definitely disappear. How can this problem be solved? Let's see how Insus. NET starts.
In the Repeater control, add an OnItemCreated event:
Go to the. aspx. cs code page to write the above event processing logic, copy the code in the OnItemDataBound event to the OnItemCreated event, and make some modifications.
In the OnItemCreated event, only the user control is dynamically loaded. The code assigned to the user control is removed. What about the OnItemDataBound event? Let's see:
On the contrary, this event removes the code that dynamically loads the user control and changes it To the value assignment function.
Why can it run normally if it needs to be written like this?
Because.