Some people have read the title of the article. Maybe the first response is: Do you need to write an article to this point? Directly UpdatePanel. Visible = false (as the saying goes: Think about it with your ass, haha ~~), I thought so when implementing this code today. I did not expect an error, and the UpdatePanel was not hidden. Looking back, it is not difficult to explain the cause of Ineffective performance. The reason why we use UpdatePanel is to implement partial refresh. Every refresh uses UpdatePanel as a container. Since it is a container, it cannot be changed, but another way to make UpdatePanel invisible is to make the div generated by UpdatePanel disappear from the DOM. Since the refreshed containers disappear, what is used for refresh is simply a daydream ~.
Client Solution
So I searched for this question on the MSDN Forum. Several posts asked this question, but the answer I saw was basically a piece of javascript. I set the display of the div generated by UpdatePanel to none, this is indeed a feasible solution, but this method will result in inconsistent control states on the server side and the client side (unless you plan to write a JavaScript code yourself to update the server status ), once full postback is performed, the user may see this UpdatePanel again. What's more, this hidden code usually needs to execute some server-side judgment logic, but it may not achieve the expected results on the client side.
Prompt
In ASP. NET, if the control's Visible is false, the entire control will not be rendered, that is, there will be no HTML elements (such as span, div, a, etc ).
Server Solution
The first thing that comes to mind is the UpdatePanel Panel. Since there is no way to refresh yourself, let the parent UpdatePanel refresh the sub-Panel. Technically, this is feasible, but pay attention to it, the div generated by the Panel cannot contain any elements, and the UpdatePanel cannot set the width and height. This is because div is a block by default, but without the width and height, it will not occupy any space, otherwise it will act as a placeholder. Once the Visible of the sub-Panel is changed to false, the code generated by UpdatePanel and its sub-elements is as follows:
<Div id = "UpdatePanel1"> </div>
This is the solution we need!