在自定义控件中加入一个 public 属性,该属性返回 calendar控件中选择的当前日期。当通过该属性获取了日期之后,将 mycalendar.Visible 设为 false;
解决方案 »
- XML读显示在Repeater问题
- webservice中struct的问题
- primarykey 2个字段问题(C#)~~~~~~~~~可行马上结帐,在线等
- 那位兄弟有FCKeditor的.net版
- 这里人多,所以从图表版过来问了,crystal report 问题
- 关于asp.net2.0菜单(非常简单)
- 水晶报表的重要问题
- 怎么样判断文本框中输入的是否是整数?(C#)
- 一个给大虾们送分的关于TextBox的textchange事件问题,快进啊
- ASP.net做的网站发布的配置!
- 文本回车换行的显示问题,焦急等待散分中!
- 上帝们,请问如何在不用CommandBuilder的情况下使用Adapter的Update方法,能不能自己构造其中的SQL语句,如果可以,其中的SQL语句的格式
protected Calendar1 mycalendar;
protected System.Web.UI.WebControls.Label Label8;
如果你的页面上,有两个以上的控件,那么你可以看到这句话的位置何意思的。
我在自定义控件中加入了:
Public Property getSelectDate() As Date
Get
getSelectDate = CalendarSet.VisibleDate
CalendarSet.Visible = False
End Get
Set(ByVal Value As Date)
getSelectDate = Value
CalendarSet.VisibleDate = getSelectDate
End Set
End Property之后在页面中使用时(Label1.Text = calendar1.getSelectDate())提示:
getSelectDate不是System.Web.UI.UserControl的成员,
会是什么问题呢,是我写借了吗
(Protected WithEvents calendar1 As System.Web.UI.UserControl)
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents calendar1 As System.Web.UI.UserControl
在用Label1.Text = Calendar1.getSelectDate()进就提示上面的借误.
后面的类名,是你在.ascx.vb中的类名。
代码如下
private void Calendar1_SelectionChanged(object sender, System.EventArgs e)
{
TextBox1.Text=Calendar1.SelectedDate.ToString();
Calendar1.Visible=false;
}
拜托你说清楚点好吗?
你那代码是写到哪里的,控件是test.aspx文件上件的吗?致icyer() ,
我在test.aspx.vb文件中定义了以下语句
Protected WithEvents calendar1 As System.Web.UI.UserControl
怎还读不了自定义控件中的属性项呢Calendar1.getSelectDate()?附:
自定控件的文件名及类另都为calendar
自定义控件在test.aspx文件中的ID为Calendar1
应该还不能将变量定义成那个自定义的控件吧,(因为该语句根本没有指定是哪一个自定义的控件),该定义过程该如何做好呢?
(因Protected WithEvents calendar1 As System.Web.UI.UserControl.calendar是错的)
我是不太明白,你是要把这个控件当成你的自定义控件???还是要两个控件并存,calendar不是可以读选中的日期吗。读了以后一隐藏你要隐藏的东西可以了吧。
{
get
{
return this.Calendar1.SelectedDate;
}
}
3。 在您的aspx文件中,不要使用<%@Register...%>,而使用下面的声明语句:<%@ Reference control="MyUserControl.ascx"%>4。 在您的aspx文件对应的类中,声明下面的变量,用来保存将要生成的UserControl对象: protected Control con;4. 在您的Page_Load事件中,加入下面的代码:con=LoadControl("MyUserControl.ascx");//"form1"是您的aspx文件中<form runat=server>的ID, 当然,您也可以把该对象放入其他container.Control frm=this.FindControl("form1");frm.Controls.Add(con);
Label1.Text=( (MyUserControl) con).SelectDate.ToString();this.con.Visible=false;this.con.Visible=true;5.现在,您就可以像控制aspx中的Textbox对象一样,控制UserControl对象。希望对您有所帮助。-微软全球技术中心 本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。
为了为您创建更好的讨论环境,请参加我们的用户满意度调查(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。
你已正确理解我的意思了,我回去好好用一下你的方法,我在自定义控件中使用calendar控件原因是:
web server 的calendar控件不能满足我的需要,我要在calecdar中增加一些我自已的东西.
Protected WithEvents calendar1 As System.Web.UI.UserControl.calendar我是让你把后面部分替换成*.ascx中的类名。
比如:
Protected WithEvents calendar1 As MyUserControl