I have created a folder called "Controls" in my asp.net application. In that folder are user controls (1 being DateRangePicker.ascx for example). Now I am creating a class in my app code folder and I am trying to cast something to a DateRangePicker,
DateRangePicker drp = (CambitCMS.Controls.DateRangePicker)gvListing.Parent.Parent.FindControl("ucDateRangePicker");
And I am getting the following error: Error 2 The type or namespace name 'Controls' does not exist in the namespace 'CambitCMS' (are you missing an assembly reference?)
How do I properly reference this user control in a class?
I want my "ListingsBasePage" class to reference my DateRangePicker usercontrol, but if I put a namespace around the whole user control code it breaks the user control, it says all the things like the textboxes, labels, etc dont exist in current context when a namespace is wrapped around the code.
Here is the start of the class "ListingsBasePage" where I am triyng to reference the usercontrol
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class ListingsBasePage : System.Web.UI.Page
{
protected void gvListing_OnPreRender(object sender, EventArgs e)
{
protected void gvListing_OnPreRender(object sender, EventArgs e)
{
GridView gvListing = (GridView)sender;
DateRangePicker drp = (CambitCMS.Controls.DateRangePicker)gvListing.Parent.Parent.FindControl("ucDateRangePicker");
gvListing.PageSize = drp.recordsPerPage;
}
........
And the start of the DatRangePickerControl
using System;
using System.Web.UI.HtmlControls;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Controls_DateRangePicker : System.Web.UI.UserControl
{
public String FromDate
{
get
{
return tbFromDate.Text;
}
}