> Hi,
>
[quoted text clipped - 4 lines]
> //type cast Parent property and access the public property
> }
Hi Siva,
Thank you for the good idea. I'm getting a couple of errors however while
trying to implement your idea in VB. Here's my code:
If Me.Parent Is WebForm6 Then
CType(Me.Parent, WebForm6).TestProp = "test"
End If
First error: The VS IDE is complaining about WebForm6 during design time.
It says:
"WebForm6 is a type and cannot be used as an expression."
Second error: If I eliminate the If-EndIf so I just have CType(...), then
during run-time, I get the following error:
"System.InvalidCastException: Specified cast is not valid."
WebForm6 is the parent ASPX page of this usercontrol, so I don't see why I'm
getting these errors.
Do you (or anyone else) have any idea what I'm doing wrong?
Thanks!
Ben
Siva M - 31 Oct 2005 15:40 GMT
Ben,
Try it this way:
If TypeOf Me.Page Is WebForm6 Then
CType (Me.Page, WebForm6).TestProp = "text"
End If
One correction: It is Me.Page, not Me.Parent. Sorry about it.
Siva M wrote:
> Hi,
>
[quoted text clipped - 4 lines]
> //type cast Parent property and access the public property
> }
Hi Siva,
Thank you for the good idea. I'm getting a couple of errors however while
trying to implement your idea in VB. Here's my code:
If Me.Parent Is WebForm6 Then
CType(Me.Parent, WebForm6).TestProp = "test"
End If
First error: The VS IDE is complaining about WebForm6 during design time.
It says:
"WebForm6 is a type and cannot be used as an expression."
Second error: If I eliminate the If-EndIf so I just have CType(...), then
during run-time, I get the following error:
"System.InvalidCastException: Specified cast is not valid."
WebForm6 is the parent ASPX page of this usercontrol, so I don't see why I'm
getting these errors.
Do you (or anyone else) have any idea what I'm doing wrong?
Thanks!
Ben
Ben Amada - 31 Oct 2005 23:13 GMT
> Ben,
>
[quoted text clipped - 5 lines]
>
> One correction: It is Me.Page, not Me.Parent. Sorry about it.
Works great .. thanks again!
Ben