我在我的蚊帐应用中设立了一个称为“Controls”的夹。 其中有用户控制(例如:RangePicker.ascx)。 现在,我正在我的手法中设置一个班子,我正试图向一位名叫RangePicker的人做一些事情。
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?)
我如何适当地将这一用户控制归入一个类别?
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;
}
........
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;
}
}