How do you use UpdatePanel correctly? (Asp.net)

I don't seem to have a problem with them.

I have an update panel with some checkboxes. I check them and click the "Save" button, but this forces the update panel to return (update) and they all return to empty. The re-draw method is executed before the button code.

What is the correct way to have an updated panel with checkboxes in which you can manipulate?

Edit: I think the problem could be fundamental design. I really need a complete guide on the proper use of service packs.

+6
ajax updatepanel
source share
5 answers

Code example:

<asp:UpdatePanel runat="server" UpdateMode="Conditional" ID="updatePanel1"> <ContentTemplate> <asp:CheckBox runat="server" ID="myCheckBox" Caption="CheckBox"/> <asp:Button runat="server" ID="saveButton" Caption="Save" OnClick="SaveButtonClick"/> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="saveButton" EventName="Click" /> </Triggers> </asp:UpdatePanel> 

Make sure that:

  • UpdateMode for UpdatePanel is conditional
  • SaveButton is contained in the Triggers section as a ControlID for AsyncPostBackTrigger
+10
source share

your code should look like

 if(!page.ispostback) { re-drawing(); } 

As with the Save button, you call the re-drawing () method and update your checkboxes again. Asynchronous feedback behaves and falls into the page method, the same as full postback, but updates the value in the service packs

Also check this URL. http://ajax.net-tutorials.com/controls/updatepanel-control/

+3
source share

Make sure that the “Save” button is located inside the “Update” panel to start, and if not, it is indicated as “Trigger for the update panel” in the <Triggers> section of the update panel.

 <asp:UpdatePanel ID="MyControlPanel" runat="server" UpdateMode="Conditional"> <Triggers> <asp:AsyncPostBackTrigger ControlID="SaveButton" /> </Triggers> <ContentTemplate> ... 

Can you show the code for your UpdatePanel?

+2
source share

If you use server-side controls to render checkboxes, you must add the EnableViewState="true" attribute to these controls and the update panel.

If you have checkboxes that are not server controls, then remove them from the update panel, enable only server controls inside. This causes the page to display several update panels, which are usually not a big problem.

0
source share

Add a ScriptManager object to your page if you don’t have one. Set EnablePartialRendering = "true". Put your UpdatePanel somewhere else on the page and put the content you want ajaxified in the tag in your UpdatePanel.

0
source share

All Articles