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

L

Lynn

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
 
L

Lynn

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.
 
A

Armin Zingler

Lynn said:
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?

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
 
J

John

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
 
L

Lynn

Thank you Armin!

I appreciate your help. :)

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

Take care,

Lynn
 
L

Lynn

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
 
O

Omar Abid

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top