I have this code in InfoEdition.aspx :
<%@ Page Title="" Language="C#" MasterPageFile="~/Espace_Candidat/SousCandidat.master" AutoEventWireup="true" CodeFile="InfoEdition.aspx.cs" Inherits="Espace_Candidat_InfoEdition" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ChildContent2" Runat="Server">
<div class="span9">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
</asp:Content>
In the code behind InfoEdition.aspx.cs when i try to access to the textbox :
public partial class Espace_Candidat_InfoEdition : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// THE TEXTBOX IS NOT FOUND
TextBox1.
}
}
the textbox is not found!!!
I think you should be using var txt1 = Content1.FindControl("TextBox1")
and then if the txt1
is not null use it as you would normally use TextBox1
?
var txt1 = Content1.FindControl("TextBox1");
txt1.Text = "some value";