By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,312 Members | 1,254 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,312 IT Pros & Developers. It's quick & easy.

option Strict On disallows late binding problem...help please...asp.net

P: n/a
Hello,

I have a website that is working fine. I have just turned on "option strict"
and am getting an error with the parts of my code. I have fixed everything
but this section, which has me baffled.

I am getting the error "option Strict On disallows late binding", and the
error is referring to this line of code: (3rd line in my sub below)
Select Case sender.Parent.ID

Public Sub btnNextPage_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
ViewState("CurrentPage") += 1
Select Case sender.Parent.ID
Case "pnlSelectLocation"
' do stuff here
Case "pnlFirstScreen"
' do stuff here
Case "pnlSecondScreen"
' do stuff here
Case "pnlSubmitReg"
' do stuff here
End Select
End Sub

I don't understand what the error means. I've tried various castings but
have not had any luck.

Can somebody help me to understand the issue?

Thank you,

Lynn
Jul 14 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
I am getting the error "option Strict On disallows late binding", and the
http://msdn2.microsoft.com/en-us/lib...ax(vs.80).aspx

Jul 14 '07 #2

P: n/a
Hello,

Thanks for the link...I ran across this one in my searching for this issue,
but I don't understand what it is saying.

Almost appears it is saying to turn option strict off.

"Mr. Arnold" <MR. Ar****@Arnold.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>
>I am getting the error "option Strict On disallows late binding", and the

http://msdn2.microsoft.com/en-us/lib...ax(vs.80).aspx

Jul 14 '07 #3

P: n/a
"Lynn" <ye******@hotmail.comschrieb
Hello,

I have a website that is working fine. I have just turned on "option
strict" and am getting an error with the parts of my code. I have
fixed everything but this section, which has me baffled.

I am getting the error "option Strict On disallows late binding",
and the error is referring to this line of code: (3rd line in my sub
below) Select Case sender.Parent.ID

Select Case Directcast(sender, <type of the sender>).Parent.ID

Public Sub btnNextPage_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs)
ViewState("CurrentPage") += 1
Select Case sender.Parent.ID
Case "pnlSelectLocation"
' do stuff here
Case "pnlFirstScreen"
' do stuff here
Case "pnlSecondScreen"
' do stuff here
Case "pnlSubmitReg"
' do stuff here
End Select
End Sub

I don't understand what the error means. I've tried various castings
but have not had any luck.

Can somebody help me to understand the issue?
The type of sender is Object. Not every object has a Parent property. You
know the type of the object that the argument points to, therefore you can
cast to that type.
Armin

Jul 14 '07 #4

P: n/a
Dim btn As Button = TryCast(sender, Button)
If btn IsNot Nothing Then
Select Case btn.Parent.ID
Case "pnlSelectLocation"
Case "pnlFirstScreen"
Case "pnlSecondScreen"
Case "pnlSubmitReg"
End Select
End If

J

"Lynn" <ye******@hotmail.comwrote in message
news:xI******************************@comcast.com. ..
Hello,

I have a website that is working fine. I have just turned on "option
strict" and am getting an error with the parts of my code. I have fixed
everything but this section, which has me baffled.

I am getting the error "option Strict On disallows late binding", and the
error is referring to this line of code: (3rd line in my sub below)
Select Case sender.Parent.ID

Public Sub btnNextPage_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
ViewState("CurrentPage") += 1
Select Case sender.Parent.ID
Case "pnlSelectLocation"
' do stuff here
Case "pnlFirstScreen"
' do stuff here
Case "pnlSecondScreen"
' do stuff here
Case "pnlSubmitReg"
' do stuff here
End Select
End Sub

I don't understand what the error means. I've tried various castings but
have not had any luck.

Can somebody help me to understand the issue?

Thank you,

Lynn

Jul 14 '07 #5

P: n/a
Thank you Armin!

I appreciate your help. :)

This is what did it for me:
Select Case DirectCast(sender, Button).Parent.ID

Take care,

Lynn
"Armin Zingler" <az*******@freenet.dewrote in message
news:eH**************@TK2MSFTNGP05.phx.gbl...
"Lynn" <ye******@hotmail.comschrieb
>Hello,

I have a website that is working fine. I have just turned on "option
strict" and am getting an error with the parts of my code. I have
fixed everything but this section, which has me baffled.

I am getting the error "option Strict On disallows late binding",
and the error is referring to this line of code: (3rd line in my sub
below) Select Case sender.Parent.ID


Select Case Directcast(sender, <type of the sender>).Parent.ID

>Public Sub btnNextPage_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs)
ViewState("CurrentPage") += 1
Select Case sender.Parent.ID
Case "pnlSelectLocation"
' do stuff here
Case "pnlFirstScreen"
' do stuff here
Case "pnlSecondScreen"
' do stuff here
Case "pnlSubmitReg"
' do stuff here
End Select
End Sub

I don't understand what the error means. I've tried various castings
but have not had any luck.

Can somebody help me to understand the issue?

The type of sender is Object. Not every object has a Parent property. You
know the type of the object that the argument points to, therefore you can
cast to that type.
Armin

Jul 14 '07 #6

P: n/a
Hi John,

Thank you for the help! I appreciate your time.

I used "Select Case DirectCast(sender, Button).Parent.ID" and it worked.

Take care,

Lynn

"John" <jo**@donotspam.invalidwrote in message
news:Or**************@TK2MSFTNGP03.phx.gbl...
Dim btn As Button = TryCast(sender, Button)
If btn IsNot Nothing Then
Select Case btn.Parent.ID
Case "pnlSelectLocation"
Case "pnlFirstScreen"
Case "pnlSecondScreen"
Case "pnlSubmitReg"
End Select
End If

J

"Lynn" <ye******@hotmail.comwrote in message
news:xI******************************@comcast.com. ..
>Hello,

I have a website that is working fine. I have just turned on "option
strict" and am getting an error with the parts of my code. I have fixed
everything but this section, which has me baffled.

I am getting the error "option Strict On disallows late binding", and the
error is referring to this line of code: (3rd line in my sub below)
Select Case sender.Parent.ID

Public Sub btnNextPage_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
ViewState("CurrentPage") += 1
Select Case sender.Parent.ID
Case "pnlSelectLocation"
' do stuff here
Case "pnlFirstScreen"
' do stuff here
Case "pnlSecondScreen"
' do stuff here
Case "pnlSubmitReg"
' do stuff here
End Select
End Sub

I don't understand what the error means. I've tried various castings but
have not had any luck.

Can somebody help me to understand the issue?

Thank you,

Lynn


Jul 14 '07 #7

P: n/a
On Jul 13, 6:55 pm, "Lynn" <yeltn...@hotmail.comwrote:
Hello,

I have a website that is working fine. I have just turned on "option strict"
and am getting an error with the parts of my code. I have fixed everything
but this section, which has me baffled.

I am getting the error "option Strict On disallows late binding", and the
error is referring to this line of code: (3rd line in my sub below)
Select Case sender.Parent.ID

Public Sub btnNextPage_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
ViewState("CurrentPage") += 1
Select Case sender.Parent.ID
Case "pnlSelectLocation"
' do stuff here
Case "pnlFirstScreen"
' do stuff here
Case "pnlSecondScreen"
' do stuff here
Case "pnlSubmitReg"
' do stuff here
End Select
End Sub

I don't understand what the error means. I've tried various castings but
have not had any luck.

Can somebody help me to understand the issue?

Thank you,

Lynn
Hi,
Option Strict don't allow the program to do string to integer or
different type conversation so make sure that you don't need to
convert string to integer or to display string as integer and Option
strict must work well
Omar Abid
http://groups.google.com/group/VB2005?lnk=li

Jul 14 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.