How to Update the UpdatePanel from Server Side in Asp.Net

Leave a Comment
Updating the panel form code behind is easy, you need to call the public method Update() in the code behind and rest will be taken care.

Deafult.aspx

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
            <h4>Inside UpdatePanel - 1</h4>
                <asp:Label ID="lblUpdatePanel1st" runat="server" EnableViewState="false" /> <br />
                <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="RefreshTheTime" />
            </ContentTemplate>
        </asp:UpdatePanel>

Default.aspx.cs
protected void RefreshTheTime(object sender, EventArgs e)
    {
        lblUpdatePanel1st.Text = DateTime.Now.ToString();
     
        // try commenting following line and see that time will not be updated
        UpdatePanel2.Update();    }

0 comments:

Post a Comment