gpt4 book ai didi

asp.net - 如何为 ASP.net UserControl 指定命名空间?

转载 作者:行者123 更新时间:2023-12-02 10:03:57 29 4
gpt4 key购买 nike

我在 ASP.net 中有一个 UserControl:

GrobSelector.ascx.cs:

...
public partial class GrobSelector : System.Web.UI.UserControl
{
...

我想将此类包装在命名空间中:

GrobSelector.ascx.cs:

...
namespace GrobSelectorNamespace
{
public partial class GrobSelector : System.Web.UI.UserControl
{
...
...
}

除了现在代码无法编译:

public partial class GrobSelector : System.Web.UI.UserControl

Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl).

将 ASP.net UserControl 放入命名空间的正确方法是什么?

<小时/>

奖金闲聊

前面的代码文件包含:

GrobSelector.ascx:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="GrobSelector.ascx.cs" 
Inherits="GrobSelector" %>

奖励阅读

最佳答案

您收到的错误正确地解释了它。

您应该更改“in-front”文件,以便 Inherits 属性考虑控件类所在的命名空间:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="VacationSelector.ascx.cs" 
Inherits="VacationSelectorNamespace.VacationSelector" %>

关于asp.net - 如何为 ASP.net UserControl 指定命名空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10789711/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com