UpdatePanel Full Postback

Greetings, here is the script.

I have both an .aspx page with and updatepanel like this

<asp:UpdatePanel id="uPanelMain" runat="server"> <ContentTemplate> <uc:Calendar id="ucCalendar" runat="server" Visible="true" /> <uc:Scoring id="ucScoring" runat="server" Visible="false" /> </ContentTemplate> 

The ucCalendar control is loaded first and it contains a grid like this

 <asp:DataGrid CssClass="grid" ID="gridGames" runat="server" AutoGenerateColumns="False" HeaderStyle-CssClass="gridHeader" ItemStyle-CssClass="gridScoringRow" GridLines="None" ItemStyle-BackColor="#EEEEEE" AlternatingItemStyle-BackColor="#F5F5F5" OnEditCommand="doScoreGame" OnDeleteCommand="doEditGame" OnCancelCommand="printLineup" OnItemDataBound="gridDataBound"> <Columns> <asp:TemplateColumn > <ItemTemplate> <asp:CheckBox ID="chkDelete" runat="server" /> </ItemTemplate> </asp:TemplateColumn> <asp:BoundColumn DataField="idGame" Visible="false" /> <asp:BoundColumn DataField="isClose" Visible="false" /> <asp:TemplateColumn HeaderText="Status"> <ItemTemplate> <asp:Image ID="imgStatus" runat="server" ImageUrl="~/img/icoX.png" alt="icoStatus" /> </ItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn> <ItemTemplate> <asp:LinkButton ID="linkScore" runat="server" CommandName="Edit" Text="Score" /> </ItemTemplate> </asp:TemplateColumn> </Columns> </asp:DataGrid> 

So, when I click "linkButton", the code name userControl calls the public method in .aspx as follows:

From userControl

  protected void doScoreGame(object sender, DataGridCommandEventArgs e) { ((GM)this.Page).showScoring(null, null); } 

On the .aspx page

 public void showScoring(object sender, EventArgs e) { removeLastLoadedControl(); ucScoring.Visible = true; } 

So here is the problem:

When you change the visible attribute of the ucScoring control, two inverse processes occur.

The first postback is ok, handled by updatePanel.

The second postback is the full postback, and I really don't understand why this is happening.

I'm really lost here, please help!

thanks

Mother

+4
source share
2 answers

You fire the event manually, which UpdatePanel is not aware of. You need to associate this event with your control and register it:

 ScriptManager.RegisterAsyncPostBack(ucScoring); 
+1
source

I am wondering what happens in the removeLastLoadedControl () method.

0
source

All Articles