UpdatePanel Full Postback

Posted by Korivo on Stack Overflow See other posts from Stack Overflow or by Korivo
Published on 2009-05-01T13:54:39Z Indexed on 2010/04/05 7:03 UTC
Read the original article Hit count: 245

Filed under:
|
|
|

Greetings, here is the scenario.

I have and .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 control ucCalendar 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 the "linkButton", the codebehind of the userControl calls a public method in the .aspx as this:

From the userControl

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

From the .aspx page

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

So, here comes the problem:

There are two postbacks taking place when I change the visible attribute of the ucScoring control.

The first postback is fine, it's handled by the updatePanel.

The second postback is a full postback, and i really don't understand why it is happening.

I'm really lost here, please help!

Thanks

Mat

© Stack Overflow or respective owner

Related posts about updatepanel

Related posts about AJAX