I have a problem with the update panel. I have made this table, and in that table i have two labels ("lblResult" and "lblCheat") which i need to be updated every time the button "btnCheck" or "ImageButton1" are clicked. When I click the next button, the whole table is updated, and it works just fine with the code i have.
I don't understand why aren't the labels updating since I am using the update panel the same way with the "btnNext" button and with the "btnCheck" and "ImageButton1"
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<center>
<asp:Label ID="lblSound" runat="server" Visible="False"></asp:Label>
<table>
<tr>
<td>
<asp:Label ID="Label3" runat="server" Text="Sentence: "></asp:Label></td>
<td colspan="2">
<center>
<asp:Label ID="lblSentence" runat="server" Text=""></asp:Label>
</center>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="Audio: "></asp:Label>
</td>
<td colspan="2">
<audio controls="">
<source src="Sound/<%=FilePath %>" />
</audio>
</td>
</tr>
<tr>
<td style="height: 11px">
<asp:Label ID="Label1" runat="server" Text="Write the correct word: "></asp:Label>
</td>
<td style="height: 11px">
<asp:TextBox ID="txtWord" runat="server" ontextchanged="txtWord_TextChanged"></asp:TextBox>
</td>
<td style="height: 11px">
<center>
<asp:Button ID="btnCheck" runat="server" onclick="btnCheck_Click"
Text="Check" />
<asp:ImageButton ID="ImageButton1" runat="server" Height="30px"
ImageUrl="~/Besilka/Question-mark-icon.png" onclick="ImageButton1_Click"
Width="30px" />
</center>
</td>
</tr>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<tr>
<td>
<center>
<asp:Label ID="lblResult" runat="server"></asp:Label>
</center>
</td>
<td>
<center>
<asp:Label ID="lblCheat" runat="server" Text=""></asp:Label>
</center>
</td>
</tr>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnCheck" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="ImageButton1" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</table>
</center>
<asp:Button ID="btnNext" runat="server" onclick="btnNext_Click" Text="Next" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnNext" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
Thanks in advance!
Try setting your nested update panel UpdateMode="Conditional"
.
See this arcticle:
Specifically read "How UpdatePanel Controls Are Refreshed", it actually talks about UpdateMode and nesting update panels.
http://msdn.microsoft.com/en-us/library/bb386454%28v=vs.100%29.aspx
Update panels take a bit getting use to :)