Multiple custom controls on aspx page

I have a page that dynamically loads multiple custom controls on a page. I have multiple buttons on each custom control that fires a server side event that does some processing related to the custom control that triggers the action.

The problem I'm having is that clicking this button causes the entire page to reload (since all dynamically loaded controls need to be reloaded on every postback) for all custom controls that make the page very slow.

Is there a way to tell .NET to ignore other custom controls when the user interacts with one of the user controls?

All custom controls are in service packs that have an installed mode.

0


a source to share


3 answers


Ditch the refresh bars and switch to using jquery and JSON.

You can focus your code a little more and should be able to give up all the management crap.



The main problem is that service packs still require a full page to send back only the tiny bit of data you want. Moving towards jquery combined with page methods or web service methods, your page doesn't have to be rebuilt for every panel refresh.

+3


a source


To answer your question specifically. No. ".NET shouldn't ignore other custom controls." You can of course say that your application ignores everything. Perhaps you are missing instructions if (!Page.IsPostBack) {}

?



0


a source


You should be able to use UpdatePanels in the scenario you described. There must be something specific to your implementation causing the entire page to refresh. I would suggest removing it to isolate the problem. I created the following sample and it worked as expected ... only the updated UpdatePanel was updated:

  • Made two custom controls that display a new GUID in the shortcut on every page load.
  • Created a test page with two UpdatePanels. Each UpdatePanel has an empty PlaceHolder control and a button to activate the async postback.
  • The Page_Init page of the test page uses LoadControl to instantiate custom controls and add them to the appropriate PlaceHolder (ph.Controls.Add ()).

When I click on any button inside the UpdatePanel, only that panel is updated (even though LoadControl is called twice on each async postback to recreate the control hierarchy).

0


a source







All Articles