TestPage (.aspx)

C# in Depth, 3rd Edition

<%@ Page Language=”C#” AutoEventWireup=”false” CodeBehind=”TestPage.aspx.cs” Inherits=”TestChange.TestPage” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=”https://www.w3.org/1999/xhtml”>

<head runat=”server”>

<title>Change the text of the Label control from the code-behind</title>



<form id=”form1″ runat=”server”>


<asp:Label ID=”LabelTest” runat=”server” Text=”My test label”></asp:Label>





Test page code-behind (.cs)


// TestPage.aspx.cs


protected void Page_Load(object sender, EventArgs e)


// changing text from code behind

LabelTest.Text = “Changed from code behind”;