views:

1124

answers:

2

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

A: 

I'm curious as to what is going on within the removeLastLoadedControl() method.

Chris Lively
A: 

You are firing an event manually that the UpdatePanel does not know about. You will need to tie that event to your control and register it:

ScriptManager.RegisterAsyncPostBack(ucScoring);
rick schott