I have a User Control (myUserControl.ascx) with the code:
<div id="content">
TEST USER CONTROL
<div>
that is called from a webpart:
protected override void OnLoad(EventArgs e) {
Control c = Page.LoadControl(_ascxPath);
if (c != null)
{
this.Controls.Add(c);
}
}
since here it's all ok.
Now I want to add a code-behind to this User Control
1) I created myUserControl.ascx.cs
public partial class SP4ITeditXML : UserControl
{
public string select1 = "test text";
}
2) I changed the myUserControl.ascx:
<%@ Control Language="C#" CodeBehind="myUserControl.ascx.cs"%>
<div id="content">
TEST USER CONTROL
<% Response.Write(this.select1); %>
<div>
but then I get the error CS0117 (myUserControl.ascx not contains a definition for select1).
What I'm doing wrong?