Disable usercontrol

How to disable user control so that the load_page is not completed? Enabled does not exist for usercontrol and Visible does not work, it just hides usercontrol, but page loading is done.

+4
source share
2 answers

Do it:

Add this at the top of the page <% @Reference Control = "~ / MyControl.ascx"%>

Then, when you need a control, just add it to where you want it, like this

ControlPlaceHolder.Controls.Add (Page.LoadControl ("~ / MyControl.ascx"))

This way, management will only load when you need it.

+3
source

You can remove the control before rendering starts with this.Controls.Remove(xxx) in preInit , but you would like for this to happen sequentially. EG. if you remove the control on the first request service, and then enable it on the callback, there may be a problem of deserializing the view state. may be. worth taking a picture

0
source

Source: https://habr.com/ru/post/1301421/


All Articles