2008-11-18 141 views
3

我正在使用.NET2.0。比方说,一个有txtInput和btnSomeAction自定义命名空间代码后面的.aspx页面

​​

一个简单的aspx表单然后窗体后面的代码中我有

Protected Sub btnSomeAction_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSomeAction.Click 
    Dim s As String 
    s = txtInput.Text 
End Sub 

这一切工作正常。

然后我想代码添加到自定义空间像

Namespace mycustomnamespace 

如果这样做,我会得到一个编译器错误:

名称“txtInput”未声明 - 如如果代码不再连接到页面

我是否需要修改aspx页面以包含名称空间?,那么部分类别如何?

回答

7

Do i need to modify the aspx page to include the namespace?, What about the partial class?

是的。在你的aspx文件的顶部,你应该看到类似

<%@ Page AutoEventWireup="false" Inherits="Blah.Foo.Bar" %> 

其中酒吧在代码隐藏类的名称,Blah.Foo是它的命名空间。您需要将其更改为

<%@ Page AutoEventWireup="false" Inherits="mycustomnamespace.Bar" %> 
+0

谢谢。现在,当我从页面菜单中选择“查看代码Gen文件”时,生成的代码包含自定义命名空间 – kristof 2008-11-18 14:58:07

相关问题