Hello friend, you can use Ajax UpdatePanel control in Master Page to refresh the content page only. Try the following code:
MasterPage.aspx:
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<h1>Master Page</h1>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<div>
<hr />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</ContentTemplate>
</asp:UpdatePanel>
</div>
MasterPage.aspx.cs:
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.ToString();
}
ContentPage.aspx:
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</asp:Content>
ContentPage.aspx.cs:
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.ToString();
}
In this way the content page DateTime will be refreshed in every hit of the button, but DateTime on MasterPage will remain unchanged.
Let me know if you have any further query.
- DD