UpdatePanel - Button Outside Not Postback RRS feed

  • Question

  • User-360635291 posted

    I'm a newbie with a newbie question.  I have a test page testing the UpdatePanel.  I have a Panel then UpdatePanel inside with two TextBoxes inside. TB1 has calendar extender with Postback that just puts the same date in TB2.   This works perfectly with the UpdatePanel. 

    All I want to do is have the Button postback so it will run the code behind to just put "Hello" in TB2.  The button is OUTSIDE of the UpdatePanel but inside the Panel.  It does nothing when I click it and I don't get my hello. What am I doing wrong?

        <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
            <asp:Panel ID="Panel1" runat="server">
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                        <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True"></asp:TextBox>
                        <ajaxToolkit:CalendarExtender ID="TextBox1_CalendarExtender" runat="server" BehaviorID="TextBox1_CalendarExtender" TargetControlID="TextBox1" />
                        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                <br />
                <br />
                <asp:Button ID="Button1" runat="server" Text="Button" />
    Public Class Delete
        Inherits System.Web.UI.Page
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        End Sub
        Protected Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
            TextBox2.Text = TextBox1.Text
        End Sub
        Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            TextBox2.Text = "hello"
        End Sub
    End Class

    Thanks for your help in advance from a Newbie!!!

    Saturday, April 27, 2019 2:04 AM

All replies