After the button submits the PostBack event, some Dynamically Loaded objects are lost.

Source: Internet
Author: User

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.