在背后的代码中找不到UserControl [英] Not able to find UserControl in Code Behind

查看:101
本文介绍了在背后的代码中找不到UserControl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在aspx页面上有一个日期选择器"用户控件,但在文件后面的代码中找不到.

I have a Date picker user control on my aspx page which I am not able to find in my code behind file.

objMed.StartDate = Convert.ToDateTime(txtStartDate.CalendarDate.ToString());



当设计显示控件时,尝试构建程序时出现以下错误

名称"txtStartDate"在当前上下文中不存在



While the design shows the control, I am getting the following error when I try to build the program

the name ''txtStartDate'' does not exist in the current context

推荐答案

您可以尝试使用此关键字吗?

Could you try with this keyword

objMed.StartDate = Convert.ToDateTime(this.txtStartDate.CalendarDate.ToString());


您是否添加了页面指令?
have you add page directive?
<%@ Register Src="../UserControl/Calender.ascx" TagName="Calender" TagPrefix="uc1" %>


并作为您页面上您想要的标签.


and as a tag on ur page where ever you want.

<uc1:Calender ID="txtCalender"  runat="server" />


在.cs页面上,使用ID进行调用.
如果有帮助,请不要忘记将其标记为答案. :)


On .cs page call it using Id.
Don''t forget to mark as answer if it helps. :)


这篇关于在背后的代码中找不到UserControl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆