How to change control text in code file
If you want to change text of the control in code file then you must use text property of the control in code file. Simple you can say
ControlId.Text = " Assign Text in double quotes";
lets take a simple example to change CheckBox text , alignment of the text and color of the Text.
<%@ Page
Language="C#"
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD
XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void
Button1_Click(object sender, EventArgs e)
{
CheckBox1.Text = "change text of the
control";
CheckBox1.TextAlign = TextAlign.Left;
CheckBox1.ForeColor = System.Drawing.Color.Green;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Change CheckBox Text in Code file</title>
</head>
<body>
<form id="form1" runat="server">
<asp:CheckBox ID="CheckBox1"
runat="server"
Text="CheckBox
Text Change" />
<br />
<br />
<asp:Button ID="Button1"
runat="server"
onclick="Button1_Click"
Text="Change
Text"
Width="85px"
/>
<div>
</div>
</form>
</body>
</html>