Hi all,

I'm designing a web page in ASPX. I have a few textboxes where the user enters the number of items, and a label that shows what they would currently pay if they checked out at that moment. I need help using a UpdatePanel to refresh the label when they make a change. I have a custom function called Calc() that calulates and returns the amount they owe.. So, for example, when the user changes the text in textbox8, I want the label to be updated with the new value of calc(). Heres my code for the updatepanel/label:

<asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
          <asp:UpdatePanel ID="UpdatePanel1" runat="server">
              <ContentTemplate>
                  <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="20pt" 
              style="text-align: center" Text="You owe: $0.00"></asp:Label>
              </ContentTemplate>
          </asp:UpdatePanel>

Then, in my Textbox8.TextChanged method:

Private Sub TextBox8_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox8.TextChanged
        Me.Label1.Text = "You owe: " & Calc()
        Me.UpdatePanel1.Update()
    End Sub

But that doesnt refresh the label. What am I doing wrong?

Set AutoPostBack=True of Textbox8 control.

Set AutoPostBack=True of Textbox8 control.

I did, but now it reloads the entire page, not just the UpdatePanel

What you need to do is to add triggers in your update panel and select the textbox and select the correct event.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.