属性。我究竟做错了什么?快要疯了 ... [英] Property. What am I doing wrong? Going crazy ...

查看:45
本文介绍了属性。我究竟做错了什么?快要疯了 ...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我在名称空间MyNameSpace.WebControls下有一个自定义控件,其

属性类型为验证:


''验证

私有_验证验证

< _

Bindable(True),_

类别(行为),_

DefaultValue(""),_

可本地化(真实)_


_



公共财产验证()作为验证

获取

返回_验证

结束获取

设置(ByVal值作为验证)

_Validation = value

结束集

结束财产''验证


验证是具有各种属性的类命名空间

MyNameSpace:


''验证

公共类验证


' 'isRequired

私有_IsRequired为布尔

公共属性IsRequired()为布尔值

获取

如果_IsRequired = Nothing然后

_IsRequired = False

结束如果

返回_IsRequired

结束获取

设置(ByVal值为布尔值)

_IsRequired = value

结束集

结束财产''需要


..............


结束班级


我在页面中使用我的控件如下:


Dim a As新的MyControl


MyControl.Property1 =Something


MyControl.Property2 = True


它有效!


当我添加以下属性时:


MyControl.Validation.IsRequired = False


我收到以下错误:


对象引用未设置为对象的实例。

描述:执行期间发生未处理的异常

当前的网络请求。请查看堆栈跟踪以获取更多

有关错误及其源自代码的信息。


异常详细信息:System.NullReferenceException:对象引用不

设置为对象的实例。


代码行:

MyControl.Validation.IsRequired = False


我做错了什么?


谢谢,


Miguel

解决方案

验证类如何实例化?

" shapper" < md ***** @ gmail.com在留言中写道

news:11 ********************** @ o80g2000hse。 googlegr oups.com ...


您好,


我在命名空间MyNameSpace.WebControls下有一个自定义控件,带有

类型验证的属性:


''验证

私有_验证验证

< _

Bindable(True),_

类别(行为),_

DefaultValue(""),_

可本地化(真实)_


_



公共财产验证()作为验证

获取

返回_验证

结束获取

设置(ByVal值作为验证)

_Validation = value

结束集

结束财产''验证


验证是具有各种属性的类命名空间

MyNameSpace:


''验证

公共类验证


' 'isRequired

私有_IsRequired为布尔

公共属性IsRequired()为布尔值

获取

如果_IsRequired = Nothing然后

_IsRequired = False

结束如果

返回_Is要求

结束获取

设置(ByVal值为布尔值)

_IsRequired = value

结束集
结束物业''需要


..............


结束类


我在页面中使用我的控件如下:


调暗一个新的MyControl


MyControl.Property1 =Something


MyControl.Property2 = True


它有效!


当我添加以下属性时:


MyControl.Validation.IsRequired = False


我收到以下错误:


对象引用未设置为对象的实例。

描述:执行

当前网页时发生未处理的异常请求。请查看堆栈跟踪以获取更多

有关错误及其源自代码的信息。


异常详细信息:System.NullReferenceException:对象引用不

设置为对象的实例。


代码行:

MyControl.Validation.IsRequired = False


我做错了什么?


谢谢,


Miguel



10月31日上午12:40,IfThenElse < sql_agent ... @ hotmail.comwrote:


验证类如何实例化?


" shapper" < mdmo ... @ gmail.com写信息


新闻:11 ********************** @ o80g2000hse.googlegr oups.com ...


你好,


我有一个名称空间MyNameSpace.WebControls下的自定义控件具有类型验证的

属性:


''验证

私有_验证确认

< _

Bindable(True),_

类别(行为),_

DefaultValue(""),_

可本地化(真实)_


_



公共财产验证()作为验证

获取

返回_验证

结束获取

设置(ByVal值作为验证)

_Validation = value

结束集

结束财产''验证


验证是在命名空间下具有各种属性的类

MyNameSpace:


''验证

公共类验证


''IsRequired

Private _IsRequired As Boolean

Public Property IsRequired( )作为布尔值

获取

如果_IsRequired = Nothing那么

_IsRequired = False

结束如果

返回_IsRequired

结束获取

设置(ByVal值为布尔值)

_IsRequired = value

结束集

结束财产''IsRequired


..............


End Class


我在页面中使用我的控件如下:


Dim a As New MyControl


MyControl.Property1 =" Something"


MyControl.Property2 = True


它有效!


当我添加以下属性时:


MyControl.Validation .IsRequired = False


我收到以下错误:


对象引用未设置为对象的实例。

描述:在当前Web请求执行

期间发生了未处理的异常。请查看堆栈跟踪以获取更多

有关错误及其源自代码的信息。


异常详细信息:System.NullReferenceException:对象引用不是

设置为对象的实例。


代码行:

MyControl.Validation.IsRequired = False


我做错了什么?


谢谢,


Miguel



嗯,我的代码中没有使用如下内容:

Dim val作为新验证

val.IsRequired =真实

val。 ...


MyControl.Validation = val


这是你的意思吗?


我不是这样做的。


我需要这样做吗?


但是我不能声明类型属性和然后定义它?


谢谢,

Miguel


10月31日,凌晨2:44,shapper< mdmo ... @ gmail.comwrote:


10月31日上午12:40,IfThenElse < sql_agent ... @ hotmail.comwrote:


验证类如何实例化?


" shapper" < mdmo ... @ gmail.comwrote in message


news:11 *************** *******@o80g2000hse.googlegr oups.com ...


你好,


我在命名空间MyNameSpace.WebControls下有一个自定义控件,带有

属性类型验证:


''验证

私有_Validation As验证

< _

Bindable(True),_

类别(行为),_

DefaultValue(""),_

可本地化(真实)_

_

公共财产验证()作为验证

获取

返回_验证

结束获取

设置(ByVal值作为验证)

_Validation = value

结束设置

结束属性''验证


验证是否为名称空间下的各种属性

MyNameSpace:


''验证

公共类验证


''IsRequired

私人_IsRequired As Boolean

Public Property IsRequired()As Boolean

Get

If _IsRequired = Nothing Then

_IsRequired =错误

结束如果

返回_IsRequired

结束获取

设置(ByVal值为布尔值)

_IsRequired = value

结束集

结束财产''IsRequired


..............


结束类


我在页面中使用我的控件如下:


Dim a As New MyControl


MyControl.Property1 =" Something"


MyControl.Property2 = True

< blockquote class =post_quotes>


它有效!


当我添加以下属性时:


MyControl.Validation.IsRequired = False


我收到以下错误:


对象引用未设置为对象的实例。

描述:当前Web请求执行

期间发生未处理的异常。请查看堆栈跟踪以获取更多

有关错误及其源自代码的信息。


异常详细信息:System.NullReferenceException:对象引用不是

设置为对象的实例。


代码行:

MyControl.Validation.IsRequired =假


我做错了什么?


谢谢,


Miguel



好​​吧,我的代码中没有使用如下内容:

Dim val作为新验证

val.IsRequired = True

val。 ...


MyControl.Validation = val


这是你的意思吗?


我不是这样做的。


我需要这样做吗?


但是我不能声明类型属性和然后定义它?


谢谢,

Miguel-隐藏引用的文字 -


- 显示引用的文字 -



Miguel,他的意思是Validation Class为null,这就是为什么你得到对象引用未设置为实例的原因的原因

一个对象。

你需要这样的东西


私有_验证验证=新验证


Hello,

I have a custom control under namespace MyNameSpace.WebControls with a
property of type validation:

'' Validation
Private _Validation As Validation
< _
Bindable(True), _
Category("Behavior"), _
DefaultValue(""), _
Localizable(True) _

_

Public Property Validation() As Validation
Get
Return _Validation
End Get
Set(ByVal value As Validation)
_Validation = value
End Set
End Property '' Validation

Validation is class with various properties under the namespace
MyNameSpace:

'' Validation
Public Class Validation

'' IsRequired
Private _IsRequired As Boolean
Public Property IsRequired() As Boolean
Get
If _IsRequired = Nothing Then
_IsRequired = False
End If
Return _IsRequired
End Get
Set(ByVal value As Boolean)
_IsRequired = value
End Set
End Property '' IsRequired

..............

End Class

I am using my control in a page as follows:

Dim a As New MyControl

MyControl.Property1 = "Something"

MyControl.Property2 = True

It works!

When I add the following property:

MyControl.Validation.IsRequired = False

I get the following error:

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.

On code line:
MyControl.Validation.IsRequired = False

What am I doing wrong?

Thanks,

Miguel

解决方案

Validation Class instantiated how?
"shapper" <md*****@gmail.comwrote in message
news:11**********************@o80g2000hse.googlegr oups.com...

Hello,

I have a custom control under namespace MyNameSpace.WebControls with a
property of type validation:

'' Validation
Private _Validation As Validation
< _
Bindable(True), _
Category("Behavior"), _
DefaultValue(""), _
Localizable(True) _

_

Public Property Validation() As Validation
Get
Return _Validation
End Get
Set(ByVal value As Validation)
_Validation = value
End Set
End Property '' Validation

Validation is class with various properties under the namespace
MyNameSpace:

'' Validation
Public Class Validation

'' IsRequired
Private _IsRequired As Boolean
Public Property IsRequired() As Boolean
Get
If _IsRequired = Nothing Then
_IsRequired = False
End If
Return _IsRequired
End Get
Set(ByVal value As Boolean)
_IsRequired = value
End Set
End Property '' IsRequired

..............

End Class

I am using my control in a page as follows:

Dim a As New MyControl

MyControl.Property1 = "Something"

MyControl.Property2 = True

It works!

When I add the following property:

MyControl.Validation.IsRequired = False

I get the following error:

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.

On code line:
MyControl.Validation.IsRequired = False

What am I doing wrong?

Thanks,

Miguel



On Oct 31, 12:40 am, "IfThenElse" <sql_agent...@hotmail.comwrote:

Validation Class instantiated how?

"shapper" <mdmo...@gmail.comwrote in message

news:11**********************@o80g2000hse.googlegr oups.com...

Hello,

I have a custom control under namespace MyNameSpace.WebControls with a
property of type validation:

'' Validation
Private _Validation As Validation
< _
Bindable(True), _
Category("Behavior"), _
DefaultValue(""), _
Localizable(True) _

_

Public Property Validation() As Validation
Get
Return _Validation
End Get
Set(ByVal value As Validation)
_Validation = value
End Set
End Property '' Validation

Validation is class with various properties under the namespace
MyNameSpace:

'' Validation
Public Class Validation

'' IsRequired
Private _IsRequired As Boolean
Public Property IsRequired() As Boolean
Get
If _IsRequired = Nothing Then
_IsRequired = False
End If
Return _IsRequired
End Get
Set(ByVal value As Boolean)
_IsRequired = value
End Set
End Property '' IsRequired

..............

End Class

I am using my control in a page as follows:

Dim a As New MyControl

MyControl.Property1 = "Something"

MyControl.Property2 = True

It works!

When I add the following property:

MyControl.Validation.IsRequired = False

I get the following error:

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.

On code line:
MyControl.Validation.IsRequired = False

What am I doing wrong?

Thanks,

Miguel

Well, I am not using something in my code as follows:
Dim val As New Validation
val.IsRequired = True
val. ...

MyControl.Validation = val

Is this what you mean?

I am not doing this.

Do I need to do this?

But can''t I declare a property of type class and then define it?

Thanks,
Miguel


On Oct 31, 2:44 am, shapper <mdmo...@gmail.comwrote:

On Oct 31, 12:40 am, "IfThenElse" <sql_agent...@hotmail.comwrote:


Validation Class instantiated how?

"shapper" <mdmo...@gmail.comwrote in message

news:11**********************@o80g2000hse.googlegr oups.com...

Hello,

I have a custom control under namespace MyNameSpace.WebControls with a
property of type validation:

'' Validation
Private _Validation As Validation
< _
Bindable(True), _
Category("Behavior"), _
DefaultValue(""), _
Localizable(True) _
_
Public Property Validation() As Validation
Get
Return _Validation
End Get
Set(ByVal value As Validation)
_Validation = value
End Set
End Property '' Validation

Validation is class with various properties under the namespace
MyNameSpace:

'' Validation
Public Class Validation

'' IsRequired
Private _IsRequired As Boolean
Public Property IsRequired() As Boolean
Get
If _IsRequired = Nothing Then
_IsRequired = False
End If
Return _IsRequired
End Get
Set(ByVal value As Boolean)
_IsRequired = value
End Set
End Property '' IsRequired

..............

End Class

I am using my control in a page as follows:

Dim a As New MyControl

MyControl.Property1 = "Something"

MyControl.Property2 = True

It works!

When I add the following property:

MyControl.Validation.IsRequired = False

I get the following error:

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.

On code line:
MyControl.Validation.IsRequired = False

What am I doing wrong?

Thanks,

Miguel


Well, I am not using something in my code as follows:
Dim val As New Validation
val.IsRequired = True
val. ...

MyControl.Validation = val

Is this what you mean?

I am not doing this.

Do I need to do this?

But can''t I declare a property of type class and then define it?

Thanks,
Miguel- Hide quoted text -

- Show quoted text -

Miguel, he means that Validation Class is null and this is the reason
why you got "object reference not set to an instance of an object".
You need to have something like this

Private _Validation As Validation = New Validation


这篇关于属性。我究竟做错了什么?快要疯了 ...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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