I've got MasterPage and Content Page. On the ContentPage there is some label and i want to change it's text when clicked on button on the content page without refreshing the page.
Default.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" %>
<script runat="server">
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
Label SensorTemperatureLabel = (Label)this.Master.FindControl("SensorTemperatureLabel");
if (SensorTemperatureLabel != null)
{
SensorTemperatureLabel.Text = "TEST";
}
}
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:ImageButton ID="ImageButton1" runat="server" OnClick="ImageButton1_Click" />
</asp:Content>
MasterPage.master Part of the code with label
<div class="sidebar">
<!-- insert your sidebar items here -->
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="SensorTemperatureLabel" runat="server" Text="Label"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
</div>