Traditionally I use the regular asp.net website (created using the File > New Website). Recently, I opted to work off of a full fledged project (created using File > New Project > ASP.net Web Application).
I've been using the same custom controls for years without incident. I simply create the new website, place my CustomControls.cs file in the App_Code directory, add one line to the web.config file and I can use all of my custom server controls. When I try that with my web project I get the following error
Error 225 The type or namespace name 'DTF' could not be found in the global namespace (are you missing an assembly reference?) D:[Project Location On Drive]\AgIn02.aspx.designer.cs
My custom control file looks like this
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AjaxControlToolkit;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
namespace DTF.Web.UI
{
public class IntOnlyBox : TextBox
{
private RequiredFieldValidator rfv;
private ValidatorCalloutExtender vce;
private AjaxControlToolkit.FilteredTextBoxExtender ftb;
private string strInvalidMessage = "";
private string strValidationGroup = "";
public string ValidationGroup
{
get
{
return strValidationGroup;
}
set
{
strValidationGroup = value;
}
}
public string InvalidMessage
{
get
{
return strInvalidMessage;
}
set
{
strInvalidMessage = value;
}
}
protected override void OnInit(EventArgs e)
{
rfv = new RequiredFieldValidator();
rfv.ControlToValidate = this.ID;
rfv.ErrorMessage = "<span style=\"color:black\"><b>Required Field Missing</b><br />" + this.InvalidMessage + "</span>";
//rfv.ErrorMessage = this.InvalidMessage;
rfv.ID = "rfv" + this.ID;
rfv.Display = ValidatorDisplay.None;
rfv.SetFocusOnError = true;
rfv.EnableClientScript = true;
rfv.ValidationGroup = this.ValidationGroup;
vce = new AjaxControlToolkit.ValidatorCalloutExtender();
vce.ID = "vce" + this.ID;
vce.TargetControlID = "rfv" + this.ID;
vce.Width = 300;
ftb = new FilteredTextBoxExtender();
ftb.ID = "ftb" + this.ID;
ftb.TargetControlID = this.ID;
ftb.FilterType = FilterTypes.Numbers;
Controls.Add(rfv);
Controls.Add(vce);
Controls.Add(ftb);
}
protected override void Render(HtmlTextWriter w)
{
//w.Write(this.InvalidMessage);
base.Render(w);
rfv.RenderControl(w);
vce.RenderControl(w);
ftb.RenderControl(w);
}
}
}
my web.config entry looks like this (in the pages/controls area)
<add tagPrefix="DTF" namespace="DTF.Web.UI" />
I've tried everything I can think of to get this to work and compile. The intellisense for the custom server controls works fine, it simply won't compile.
I also get the error "The base class includes the field 'blanro', but its type (DTF.DateBoxFull) is not compatible with the type of control (DTF.DateBoxFull)."
Any idea how to fix this, and why it would work in the regular asp.net website but not in a web project?
Thanks Everyone.