用户控制页面的问题

发布于 2024-08-26 23:52:10 字数 940 浏览 6 评论 0原文

我开始放弃对这个问题进行故障排除...我有一个 .ascx 页面,其中有以下用户控件:

<td>
                <Club:DatePicker ID="dp1" runat="server" />
</td>

但是,当我尝试编写方法时,在后面的代码中:

 public System.DateTime startDateTime
        {
            get
            {
                return dp1.SelectedDate.Add(tp1.SelectedTime.TimeOfDay);
            }
            set
            {
                dp1.SelectedDate = value;
                tp1.SelectedTime = value;
            }
        }

它无法引用 dp1(dp1 是红色下划线)以及 tp1...这是为什么? 我尝试将解决方案转换为网络应用程序,但它不起作用。 尝试添加:

protected global::ClubSite dp1; 受保护的全局::ClubSite tp1;

在 ascx.designer.cs 中

,但全局以红色突出显示,

这是我的完整解决方案的链接:

http://cid-1bd707a1bb687294.skydrive.live.com/self.aspx/.Public/Permias.zip

I am starting to give up troubleshooting this issue I had... I had an .ascx page and had the following user control in it:

<td>
                <Club:DatePicker ID="dp1" runat="server" />
</td>

however in my code behind when I tried to write methods:

 public System.DateTime startDateTime
        {
            get
            {
                return dp1.SelectedDate.Add(tp1.SelectedTime.TimeOfDay);
            }
            set
            {
                dp1.SelectedDate = value;
                tp1.SelectedTime = value;
            }
        }

It can't reference dp1(dp1 is underlined in red) as well as tp1... why is this??
I've tried to convert the solution to a web application and yet it doesn't work.
Tried adding:

protected global::ClubSite dp1;
protected global::ClubSite tp1;

in the ascx.designer.cs

but then the global is highlighted in red

here's the link to my full solution:

http://cid-1bd707a1bb687294.skydrive.live.com/self.aspx/.Public/Permias.zip

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜声 2024-09-02 23:52:10

您的 DurationPicker.ascx.designer.cs 应该如下所示,加上一些注释:

namespace Permias {
    public partial class DurationPicker {
        protected global::ClubSite.DatePicker dp1;
        protected global::ClubSite.TimePicker tp1;
        protected global::ClubSite.DatePicker dp2;
        protected global::ClubSite.TimePicker tp2;
    }
}

我编辑了您的 .ascx 标记,这看起来很好,似乎是 Visual Studio 挂在您这边的东西,不允许这样做发生。您可以执行以下操作来手动触发此操作:

  1. 删除 DurationPicker.ascx.designer.cs
  2. 右键单击​​ DurationPicker.ascx
  3. 单击转换为 Web 应用程序

这应该重新生成 DurationPicker.ascx.designer.cs 文件。

Your DurationPicker.ascx.designer.cs should look like this, plus some comments:

namespace Permias {
    public partial class DurationPicker {
        protected global::ClubSite.DatePicker dp1;
        protected global::ClubSite.TimePicker tp1;
        protected global::ClubSite.DatePicker dp2;
        protected global::ClubSite.TimePicker tp2;
    }
}

I edited your .ascx markup and this appeared fine, seems to be something visual studio's hanging onto on your side that's not letting this happen. One thing you can do to trigger this manually:

  1. Delete DurationPicker.ascx.designer.cs
  2. Right click on DurationPicker.ascx
  3. Click Convert to Web Application

This should re-generate the DurationPicker.ascx.designer.cs file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文