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

problem with "Object reference not set to an instance of an object"

P: n/a
Hi,

I tried to create a class which must change the propety 'visible' of a
<linktag in the masterpage into 'false' when the user is logged. But i get
the error: "Object reference not set to an instance of an object"
for the line 'If mpg.FindControl("lkred").Visible = True Then'.

I couldn't find sofar the solution.
Any help would be appreciated ...
Thanks
Chris

the class:
---------
Imports Microsoft.VisualBasic
Public Class loginkl
Public Sub logkl()
Dim pg As New Page
Dim mpg As MasterPage
If pg.User.Identity.IsAuthenticated = True Then
If mpg.FindControl("lkred").Visible = True Then
....
End If
End Sub
End Class

code-behind:
-----------
Partial Class MasterPage
Inherits System.Web.UI.MasterPage
Protected Sub Page_Init(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Init
Dim lg As New loginkl
lg.logkl()
End Sub
End Class

masterpage.master:
------------------
<link runat="server" id="lkred" href="App_Themes/red.css" rel=Stylesheet
type="text/css" visible="true"/>

Mar 4 '07 #1
Share this Question
Share on Google+
35 Replies


P: n/a
Chris wrote:
Hi,

I tried to create a class which must change the propety 'visible' of a
<linktag in the masterpage into 'false' when the user is logged. But i get
the error: "Object reference not set to an instance of an object"
for the line 'If mpg.FindControl("lkred").Visible = True Then'.

I couldn't find sofar the solution.
Any help would be appreciated ...
Thanks
Chris

the class:
---------
Imports Microsoft.VisualBasic
Public Class loginkl
Public Sub logkl()
Dim pg As New Page
Here you are creating a completely new instance of the Page class. The
Page class is the base class for pages and doesn't contain any controls
at all.
Dim mpg As MasterPage
If pg.User.Identity.IsAuthenticated = True Then
If mpg.FindControl("lkred").Visible = True Then
The FindControl method returns a null reference. As there are no
controls in the page object, the control you are looking for can of
course not be found.
....
End If
End Sub
End Class

code-behind:
-----------
Partial Class MasterPage
Inherits System.Web.UI.MasterPage
Protected Sub Page_Init(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Init
Dim lg As New loginkl
lg.logkl()
Here you should to pass a reference to the current Page into the method,
so that it can use that to locate the control.

Better yet, why not pass a reference to the control into the method.
That way you don't have to use FindControl to locate it, and the method
can be used to hide any control that you like, not only a control named
"lkred".

I am not sure, but the Init event of the master page might also occur
too early to access the controls of the page. If the markup of the page
has not yet been parsed, the page does not yet contain any controls.
Then you have to use an even that occurs later in the cycle.
End Sub
End Class

masterpage.master:
------------------
<link runat="server" id="lkred" href="App_Themes/red.css" rel=Stylesheet
type="text/css" visible="true"/>

--
Göran Andersson
_____
http://www.guffa.com
Mar 4 '07 #2

P: n/a
Correction: I see now that you look for the control in the MasterPage
object, not in the Page object.

The same appplies, though, but the actual error occurs because you have
just declared a reference to a master page, and haven't assign any value
to it. When you try to use the reference, it's null.

(Are you sure that this is the actual code that you are using? I would
expect a compiler error as you are trying to use a variable that hasn't
been assigned any value.)

You have to send a reference into the method, either a reference to the
actual master page, or a reference to the control. The base class for
master pages can not be used to access controls in any specific master page.

--
Göran Andersson
_____
http://www.guffa.com
Mar 4 '07 #3

P: n/a
Hi, thanks

I changed this line in the class:
Dim mpg As New MasterPage

I have no error anymore, but instead of changing the theme from red into
green, it remains red. So at least one test remains false:
If pg.User.Identity.IsAuthenticated = True Then
If mpg.FindControl("lkred").Visible = True Then

Could you please give me the right code for doing what you told me?
The same appplies, though, but the actual error occurs because you have
just declared a reference to a master page, and haven't assign any value
to it.

and

You have to send a reference into the method, either a reference to the
actual master page, or a reference to the control

thanks again

Mar 4 '07 #4

P: n/a
You are only declaring mpg as a variable, not an instance of a MasterPage
class, so when you write:

If mpg.FindControl("lkred").Visible = True Then

you get the error because "mpg" has not been set to an instance of a
MasterPage class.

You need to either instantiate mpg: Dim mpg As NEW MasterPage

or set mpg equal to an already created instance of a MasterPage:

Dim foo As New MasterPage
Dim mpg As MasterPage = foo

-Scott

"Chris" <??**@nospam.dcwrote in message
news:el**************@TK2MSFTNGP06.phx.gbl...
Hi,

I tried to create a class which must change the propety 'visible' of a
<linktag in the masterpage into 'false' when the user is logged. But i
get the error: "Object reference not set to an instance of an object"
for the line 'If mpg.FindControl("lkred").Visible = True Then'.

I couldn't find sofar the solution.
Any help would be appreciated ...
Thanks
Chris

the class:
---------
Imports Microsoft.VisualBasic
Public Class loginkl
Public Sub logkl()
Dim pg As New Page
Dim mpg As MasterPage
If pg.User.Identity.IsAuthenticated = True Then
If mpg.FindControl("lkred").Visible = True Then
....
End If
End Sub
End Class

code-behind:
-----------
Partial Class MasterPage
Inherits System.Web.UI.MasterPage
Protected Sub Page_Init(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Init
Dim lg As New loginkl
lg.logkl()
End Sub
End Class

masterpage.master:
------------------
<link runat="server" id="lkred" href="App_Themes/red.css" rel=Stylesheet
type="text/css" visible="true"/>

Mar 4 '07 #5

P: n/a
Chris wrote:
Hi, thanks

I changed this line in the class:
Dim mpg As New MasterPage

I have no error anymore, but instead of changing the theme from red into
green, it remains red. So at least one test remains false:
If pg.User.Identity.IsAuthenticated = True Then
If mpg.FindControl("lkred").Visible = True Then

Could you please give me the right code for doing what you told me?
The same appplies, though, but the actual error occurs because you have
just declared a reference to a master page, and haven't assign any value
to it.

and

You have to send a reference into the method, either a reference to the
actual master page, or a reference to the control

thanks again
Here's an example of how you send a reference to a control into a method:

SomeMethod(theControl)

Here's how you declare the method to accept the reference:

Public Sub SomeMethod(link As Control)

--
Göran Andersson
_____
http://www.guffa.com
Mar 5 '07 #6

P: n/a
Hi, thanks to you too. i did what you told me:but i still have the same
error for the same line "'If mpg.FindControl("lkred").Visible = True Then'.
I show you the whole code to be sure ...(i also tried with Protected Sub
Page_Load instead of Protected Sub Page_Init).
masterpage:
-----------
<head runat="server">
<link runat="server" id="Lkred" href="App_Themes/red/red.css"
rel=Stylesheet type="text/css" visible="true"/>
<link runat="server" id="lkgreen" href="App_Themes/green/green.css"
rel=Stylesheet type="text/css" visible="false" />
</head>

classe:
-------
Imports Microsoft.VisualBasic

Public Class loginkl
Public Sub logkl()
Dim pg As New Page
Dim foo As New MasterPage
Dim mpg As MasterPage = foo
If pg.User.Identity.IsAuthenticated = True Then
If mpg.FindControl("lkred").Visible = True Then
mpg.FindControl("lkred").Visible = False
mpg.FindControl("lkgreen").Visible = True
Else
mpg.FindControl("lkred").Visible = True
mpg.FindControl("lkgreen").Visible = False
End If
End If
End Sub
End Class

code-behind of masterpage:
---------------------------
Partial Class MasterPage
Inherits System.Web.UI.MasterPage
Protected Sub Page_Init(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Init
Dim lg As New loginkl
lg.logkl()
End Sub
End Class
Mar 5 '07 #7

P: n/a
In the masterpage, the id of the control is Lkred and not lkred.

mpg.FindControl("lkred") returns nothing becuase it should be
mpg.FindControl("Lkred")

"Chris" <??**@nospam.dcwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Hi, thanks to you too. i did what you told me:but i still have the same
error for the same line "'If mpg.FindControl("lkred").Visible = True
Then'.
I show you the whole code to be sure ...(i also tried with Protected Sub
Page_Load instead of Protected Sub Page_Init).
masterpage:
-----------
<head runat="server">
<link runat="server" id="Lkred" href="App_Themes/red/red.css"
rel=Stylesheet type="text/css" visible="true"/>
<link runat="server" id="lkgreen" href="App_Themes/green/green.css"
rel=Stylesheet type="text/css" visible="false" />
</head>

classe:
-------
Imports Microsoft.VisualBasic

Public Class loginkl
Public Sub logkl()
Dim pg As New Page
Dim foo As New MasterPage
Dim mpg As MasterPage = foo
If pg.User.Identity.IsAuthenticated = True Then
If mpg.FindControl("lkred").Visible = True Then
mpg.FindControl("lkred").Visible = False
mpg.FindControl("lkgreen").Visible = True
Else
mpg.FindControl("lkred").Visible = True
mpg.FindControl("lkgreen").Visible = False
End If
End If
End Sub
End Class

code-behind of masterpage:
---------------------------
Partial Class MasterPage
Inherits System.Web.UI.MasterPage
Protected Sub Page_Init(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Init
Dim lg As New loginkl
lg.logkl()
End Sub
End Class
Mar 5 '07 #8

P: n/a
Hi,

It's true but it doesn't matter, i thing ... it's not case sensitive
(VB.net) (i tried with both lower and uppercase).
Still same error.
"Stephany Young" <noone@localhostschreef in bericht
news:%2****************@TK2MSFTNGP02.phx.gbl...
In the masterpage, the id of the control is Lkred and not lkred.

mpg.FindControl("lkred") returns nothing becuase it should be
mpg.FindControl("Lkred")

"Chris" <??**@nospam.dcwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>Hi, thanks to you too. i did what you told me:but i still have the same
error for the same line "'If mpg.FindControl("lkred").Visible = True
Then'.
I show you the whole code to be sure ...(i also tried with Protected Sub
Page_Load instead of Protected Sub Page_Init).
masterpage:
-----------
<head runat="server">
<link runat="server" id="Lkred" href="App_Themes/red/red.css"
rel=Stylesheet type="text/css" visible="true"/>
<link runat="server" id="lkgreen" href="App_Themes/green/green.css"
rel=Stylesheet type="text/css" visible="false" />
</head>

classe:
-------
Imports Microsoft.VisualBasic

Public Class loginkl
Public Sub logkl()
Dim pg As New Page
Dim foo As New MasterPage
Dim mpg As MasterPage = foo
If pg.User.Identity.IsAuthenticated = True Then
If mpg.FindControl("lkred").Visible = True Then
mpg.FindControl("lkred").Visible = False
mpg.FindControl("lkgreen").Visible = True
Else
mpg.FindControl("lkred").Visible = True
mpg.FindControl("lkgreen").Visible = False
End If
End If
End Sub
End Class

code-behind of masterpage:
---------------------------
Partial Class MasterPage
Inherits System.Web.UI.MasterPage
Protected Sub Page_Init(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Init
Dim lg As New loginkl
lg.logkl()
End Sub
End Class

Mar 5 '07 #9

P: n/a
As I have explained already, you can not access the controls of a
specific master page by creating an instance of the base class for
master pages. You need a reference to the actual master page that
contains the control.

Read what I have written in my other posts in this thread about sending
a reference to the method.

Chris wrote:
Hi, thanks to you too. i did what you told me:but i still have the same
error for the same line "'If mpg.FindControl("lkred").Visible = True Then'.
I show you the whole code to be sure ...(i also tried with Protected Sub
Page_Load instead of Protected Sub Page_Init).
masterpage:
-----------
<head runat="server">
<link runat="server" id="Lkred" href="App_Themes/red/red.css"
rel=Stylesheet type="text/css" visible="true"/>
<link runat="server" id="lkgreen" href="App_Themes/green/green.css"
rel=Stylesheet type="text/css" visible="false" />
</head>

classe:
-------
Imports Microsoft.VisualBasic

Public Class loginkl
Public Sub logkl()
Dim pg As New Page
Dim foo As New MasterPage
Dim mpg As MasterPage = foo
If pg.User.Identity.IsAuthenticated = True Then
If mpg.FindControl("lkred").Visible = True Then
mpg.FindControl("lkred").Visible = False
mpg.FindControl("lkgreen").Visible = True
Else
mpg.FindControl("lkred").Visible = True
mpg.FindControl("lkgreen").Visible = False
End If
End If
End Sub
End Class

code-behind of masterpage:
---------------------------
Partial Class MasterPage
Inherits System.Web.UI.MasterPage
Protected Sub Page_Init(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Init
Dim lg As New loginkl
lg.logkl()
End Sub
End Class
--
Göran Andersson
_____
http://www.guffa.com
Mar 5 '07 #10

P: n/a
I tried it without class, defining everything in the code-behind of the
master page and it works.
If Page.User.Identity.IsAuthenticated Then
If Lkred.Visible = True Then
Lkred.Visible = False
lkgreen.Visible = True
Else
Lkred.Visible = True
lkgreen.Visible = False
End If
End If
I want to learn how to do the same with a class, but sorry, i can't find the
right code working with a class.
I tried a lot of things without succes:

- in web.config, i added a reference: <pages
masterPageFile="~/MasterPage.master">
- this is the updated class file:
Public Class loginkl
Public Sub logkl(ByVal link As Control)
Dim pg As New Page
Dim foo As New MasterPage
Dim mpg As MasterPage = foo
If pg.User.Identity.IsAuthenticated = True Then
If mpg.FindControl("lkred").Visible = True Then
mpg.FindControl("lkred").Visible = False
mpg.FindControl("lkgreen").Visible = True
Else
mpg.FindControl("lkred").Visible = True
mpg.FindControl("lkgreen").Visible = False
End If
End If
End Sub
End Class

- the updated code-behind of master page
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Init
Dim lg As New loginkl
lg.logkl(???)
End Sub

Can anybody tell me finally what i need to change in this precise code?
Thanks
Mar 5 '07 #11

P: n/a
Chris wrote:
I tried it without class, defining everything in the code-behind of the
master page and it works.
If Page.User.Identity.IsAuthenticated Then
If Lkred.Visible = True Then
Lkred.Visible = False
lkgreen.Visible = True
Else
Lkred.Visible = True
lkgreen.Visible = False
End If
End If
I want to learn how to do the same with a class, but sorry, i can't find the
right code working with a class.
I tried a lot of things without succes:

- in web.config, i added a reference: <pages
masterPageFile="~/MasterPage.master">
- this is the updated class file:
Public Class loginkl
Public Sub logkl(ByVal link As Control)
As you want to change two controls, you want to send to controls to the
method:

Public Sub logkl(link1 As Control, link2 as Control)
Dim pg As New Page
Dim foo As New MasterPage
Dim mpg As MasterPage = foo
Skip the masterpage references. You don't need them as you have
reference to the controls.
If pg.User.Identity.IsAuthenticated = True Then
If mpg.FindControl("lkred").Visible = True Then
Use the reference to the control instead of searching for it:

If link1.Visible Then
mpg.FindControl("lkred").Visible = False
mpg.FindControl("lkgreen").Visible = True
Same here:

link1.Visible = False
link2.Visible = True
Else
mpg.FindControl("lkred").Visible = True
mpg.FindControl("lkgreen").Visible = False
link1.Visible = True
link2.Visible = False
End If
End If
End Sub
End Class

- the updated code-behind of master page
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Init
Dim lg As New loginkl
lg.logkl(???)
lg.logkl(Lkred, lkgreen)
End Sub

Can anybody tell me finally what i need to change in this precise code?
Thanks


--
Göran Andersson
_____
http://www.guffa.com
Mar 5 '07 #12

P: n/a
Hi Goran,

Thanks, it works now..

"Göran Andersson" <gu***@guffa.comschreef in bericht
news:ey**************@TK2MSFTNGP03.phx.gbl...
Chris wrote:
>I tried it without class, defining everything in the code-behind of the
master page and it works.
If Page.User.Identity.IsAuthenticated Then
If Lkred.Visible = True Then
Lkred.Visible = False
lkgreen.Visible = True
Else
Lkred.Visible = True
lkgreen.Visible = False
End If
End If
I want to learn how to do the same with a class, but sorry, i can't find
the right code working with a class.
I tried a lot of things without succes:

- in web.config, i added a reference: <pages
masterPageFile="~/MasterPage.master">
- this is the updated class file:
Public Class loginkl
Public Sub logkl(ByVal link As Control)

As you want to change two controls, you want to send to controls to the
method:

Public Sub logkl(link1 As Control, link2 as Control)
> Dim pg As New Page
Dim foo As New MasterPage
Dim mpg As MasterPage = foo

Skip the masterpage references. You don't need them as you have reference
to the controls.
> If pg.User.Identity.IsAuthenticated = True Then
If mpg.FindControl("lkred").Visible = True Then

Use the reference to the control instead of searching for it:

If link1.Visible Then
> mpg.FindControl("lkred").Visible = False
mpg.FindControl("lkgreen").Visible = True

Same here:

link1.Visible = False
link2.Visible = True
> Else
mpg.FindControl("lkred").Visible = True
mpg.FindControl("lkgreen").Visible = False

link1.Visible = True
link2.Visible = False
> End If
End If
End Sub
End Class

- the updated code-behind of master page
Protected Sub Page_Init(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Init
Dim lg As New loginkl
lg.logkl(???)

lg.logkl(Lkred, lkgreen)
> End Sub

Can anybody tell me finally what i need to change in this precise code?
Thanks


--
Göran Andersson
_____
http://www.guffa.com

Mar 5 '07 #13

P: n/a
When dealing with string literals (any value in quotes), case always
matters. It's not a VB thing.

For example:

"Scott" does not equal "scott", so:

Dim A As String = "Scott"
Bim B As String = "scott"

If A = B Then
MessageBox(A & "= " & B)
Else
MessageBox(A & " <" & B)
End If

You will find that the code in the Else always runs.

"Chris" <??**@nospam.dcwrote in message
news:e5**************@TK2MSFTNGP03.phx.gbl...
Hi,

It's true but it doesn't matter, i thing ... it's not case sensitive
(VB.net) (i tried with both lower and uppercase).
Still same error.
"Stephany Young" <noone@localhostschreef in bericht
news:%2****************@TK2MSFTNGP02.phx.gbl...
>In the masterpage, the id of the control is Lkred and not lkred.

mpg.FindControl("lkred") returns nothing becuase it should be
mpg.FindControl("Lkred")

"Chris" <??**@nospam.dcwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>>Hi, thanks to you too. i did what you told me:but i still have the same
error for the same line "'If mpg.FindControl("lkred").Visible = True
Then'.
I show you the whole code to be sure ...(i also tried with Protected Sub
Page_Load instead of Protected Sub Page_Init).
masterpage:
-----------
<head runat="server">
<link runat="server" id="Lkred" href="App_Themes/red/red.css"
rel=Stylesheet type="text/css" visible="true"/>
<link runat="server" id="lkgreen" href="App_Themes/green/green.css"
rel=Stylesheet type="text/css" visible="false" />
</head>

classe:
-------
Imports Microsoft.VisualBasic

Public Class loginkl
Public Sub logkl()
Dim pg As New Page
Dim foo As New MasterPage
Dim mpg As MasterPage = foo
If pg.User.Identity.IsAuthenticated = True Then
If mpg.FindControl("lkred").Visible = True Then
mpg.FindControl("lkred").Visible = False
mpg.FindControl("lkgreen").Visible = True
Else
mpg.FindControl("lkred").Visible = True
mpg.FindControl("lkgreen").Visible = False
End If
End If
End Sub
End Class

code-behind of masterpage:
---------------------------
Partial Class MasterPage
Inherits System.Web.UI.MasterPage
Protected Sub Page_Init(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Init
Dim lg As New loginkl
lg.logkl()
End Sub
End Class


Mar 6 '07 #14

P: n/a
The reason that the code in the Else always runs is not because of the
case of the string, but because of the fact that the Controls collection
is always empty.

Scott M. wrote:
When dealing with string literals (any value in quotes), case always
matters. It's not a VB thing.

For example:

"Scott" does not equal "scott", so:

Dim A As String = "Scott"
Bim B As String = "scott"

If A = B Then
MessageBox(A & "= " & B)
Else
MessageBox(A & " <" & B)
End If

You will find that the code in the Else always runs.

"Chris" <??**@nospam.dcwrote in message
news:e5**************@TK2MSFTNGP03.phx.gbl...
>Hi,

It's true but it doesn't matter, i thing ... it's not case sensitive
(VB.net) (i tried with both lower and uppercase).
Still same error.
"Stephany Young" <noone@localhostschreef in bericht
news:%2****************@TK2MSFTNGP02.phx.gbl...
>>In the masterpage, the id of the control is Lkred and not lkred.

mpg.FindControl("lkred") returns nothing becuase it should be
mpg.FindControl("Lkred")

"Chris" <??**@nospam.dcwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl.. .
Hi, thanks to you too. i did what you told me:but i still have the same
error for the same line "'If mpg.FindControl("lkred").Visible = True
Then'.
I show you the whole code to be sure ...(i also tried with Protected Sub
Page_Load instead of Protected Sub Page_Init).
masterpage:
-----------
<head runat="server">
<link runat="server" id="Lkred" href="App_Themes/red/red.css"
rel=Stylesheet type="text/css" visible="true"/>
<link runat="server" id="lkgreen" href="App_Themes/green/green.css"
rel=Stylesheet type="text/css" visible="false" />
</head>

classe:
-------
Imports Microsoft.VisualBasic

Public Class loginkl
Public Sub logkl()
Dim pg As New Page
Dim foo As New MasterPage
Dim mpg As MasterPage = foo
If pg.User.Identity.IsAuthenticated = True Then
If mpg.FindControl("lkred").Visible = True Then
mpg.FindControl("lkred").Visible = False
mpg.FindControl("lkgreen").Visible = True
Else
mpg.FindControl("lkred").Visible = True
mpg.FindControl("lkgreen").Visible = False
End If
End If
End Sub
End Class

code-behind of masterpage:
---------------------------
Partial Class MasterPage
Inherits System.Web.UI.MasterPage
Protected Sub Page_Init(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Init
Dim lg As New loginkl
lg.logkl()
End Sub
End Class


--
Göran Andersson
_____
http://www.guffa.com
Mar 6 '07 #15

P: n/a
I am not talking about controls in master pages Goran. My message is in
direct response to a remark about strings not being case sensitive in VB
that was made by Chris.

My example below does not have anything to do with control collections.
"Göran Andersson" <gu***@guffa.comwrote in message
news:u3****************@TK2MSFTNGP03.phx.gbl...
The reason that the code in the Else always runs is not because of the
case of the string, but because of the fact that the Controls collection
is always empty.

Scott M. wrote:
>When dealing with string literals (any value in quotes), case always
matters. It's not a VB thing.

For example:

"Scott" does not equal "scott", so:

Dim A As String = "Scott"
Bim B As String = "scott"

If A = B Then
MessageBox(A & "= " & B)
Else
MessageBox(A & " <" & B)
End If

You will find that the code in the Else always runs.

"Chris" <??**@nospam.dcwrote in message
news:e5**************@TK2MSFTNGP03.phx.gbl...
>>Hi,

It's true but it doesn't matter, i thing ... it's not case sensitive
(VB.net) (i tried with both lower and uppercase).
Still same error.
"Stephany Young" <noone@localhostschreef in bericht
news:%2****************@TK2MSFTNGP02.phx.gbl.. .
In the masterpage, the id of the control is Lkred and not lkred.

mpg.FindControl("lkred") returns nothing becuase it should be
mpg.FindControl("Lkred")

"Chris" <??**@nospam.dcwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl. ..
Hi, thanks to you too. i did what you told me:but i still have the
same error for the same line "'If mpg.FindControl("lkred").Visible =
True Then'.
I show you the whole code to be sure ...(i also tried with Protected
Sub Page_Load instead of Protected Sub Page_Init).
>
>
masterpage:
-----------
<head runat="server">
<link runat="server" id="Lkred" href="App_Themes/red/red.css"
rel=Stylesheet type="text/css" visible="true"/>
<link runat="server" id="lkgreen" href="App_Themes/green/green.css"
rel=Stylesheet type="text/css" visible="false" />
</head>
>
classe:
-------
Imports Microsoft.VisualBasic
>
Public Class loginkl
Public Sub logkl()
Dim pg As New Page
Dim foo As New MasterPage
Dim mpg As MasterPage = foo
If pg.User.Identity.IsAuthenticated = True Then
If mpg.FindControl("lkred").Visible = True Then
mpg.FindControl("lkred").Visible = False
mpg.FindControl("lkgreen").Visible = True
Else
mpg.FindControl("lkred").Visible = True
mpg.FindControl("lkgreen").Visible = False
End If
End If
End Sub
End Class
>
code-behind of masterpage:
---------------------------
Partial Class MasterPage
Inherits System.Web.UI.MasterPage
Protected Sub Page_Init(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Init
Dim lg As New loginkl
lg.logkl()
End Sub
End Class
>



--
Göran Andersson
_____
http://www.guffa.com

Mar 6 '07 #16

P: n/a
Scott,

Your message should be true, however, it is not always, it is strange enough
that in AspNet the string literals from ADONET can be mixed uper and lower
case. (I thought I had seen this in version 1.1).

Cor

"Scott M." <s-***@nospam.nospamschreef in bericht
news:uy**************@TK2MSFTNGP05.phx.gbl...
When dealing with string literals (any value in quotes), case always
matters. It's not a VB thing.

For example:

"Scott" does not equal "scott", so:

Dim A As String = "Scott"
Bim B As String = "scott"

If A = B Then
MessageBox(A & "= " & B)
Else
MessageBox(A & " <" & B)
End If

You will find that the code in the Else always runs.

"Chris" <??**@nospam.dcwrote in message
news:e5**************@TK2MSFTNGP03.phx.gbl...
>Hi,

It's true but it doesn't matter, i thing ... it's not case sensitive
(VB.net) (i tried with both lower and uppercase).
Still same error.
"Stephany Young" <noone@localhostschreef in bericht
news:%2****************@TK2MSFTNGP02.phx.gbl...
>>In the masterpage, the id of the control is Lkred and not lkred.

mpg.FindControl("lkred") returns nothing becuase it should be
mpg.FindControl("Lkred")

"Chris" <??**@nospam.dcwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl.. .
Hi, thanks to you too. i did what you told me:but i still have the same
error for the same line "'If mpg.FindControl("lkred").Visible = True
Then'.
I show you the whole code to be sure ...(i also tried with Protected
Sub Page_Load instead of Protected Sub Page_Init).
masterpage:
-----------
<head runat="server">
<link runat="server" id="Lkred" href="App_Themes/red/red.css"
rel=Stylesheet type="text/css" visible="true"/>
<link runat="server" id="lkgreen" href="App_Themes/green/green.css"
rel=Stylesheet type="text/css" visible="false" />
</head>

classe:
-------
Imports Microsoft.VisualBasic

Public Class loginkl
Public Sub logkl()
Dim pg As New Page
Dim foo As New MasterPage
Dim mpg As MasterPage = foo
If pg.User.Identity.IsAuthenticated = True Then
If mpg.FindControl("lkred").Visible = True Then
mpg.FindControl("lkred").Visible = False
mpg.FindControl("lkgreen").Visible = True
Else
mpg.FindControl("lkred").Visible = True
mpg.FindControl("lkgreen").Visible = False
End If
End If
End Sub
End Class

code-behind of masterpage:
---------------------------
Partial Class MasterPage
Inherits System.Web.UI.MasterPage
Protected Sub Page_Init(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Init
Dim lg As New loginkl
lg.logkl()
End Sub
End Class




Mar 8 '07 #17

P: n/a
I don't think so Cor,

A string literal is always just that.

You may be referring to situations when you refer to a field name in a
database using a case that does not match the capitalization of the actual
field name.

For example, assume the following SQL statement:

SELECT * From tblCustomers WHERE NAME = "Smith"

It's up to the engine interpreting the strings to decide if it wishes to
enforce case-sensitivity. Many databases do not enforce it on field names,
but do enforce it when querying on a particular value (the WHERE clause of a
SQL statement). In other words, if the field name or string in the WHERE
clause isn't treated case-sensitively, it's because the database engine
processing the SQL statement did it that way, not because the language the
SQL statement was part of (VB.NET, C#, etc.) isn't case-sensitive.

-Scott

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:ee*************@TK2MSFTNGP04.phx.gbl...
Scott,

Your message should be true, however, it is not always, it is strange
enough that in AspNet the string literals from ADONET can be mixed uper
and lower case. (I thought I had seen this in version 1.1).

Cor

"Scott M." <s-***@nospam.nospamschreef in bericht
news:uy**************@TK2MSFTNGP05.phx.gbl...
>When dealing with string literals (any value in quotes), case always
matters. It's not a VB thing.

For example:

"Scott" does not equal "scott", so:

Dim A As String = "Scott"
Bim B As String = "scott"

If A = B Then
MessageBox(A & "= " & B)
Else
MessageBox(A & " <" & B)
End If

You will find that the code in the Else always runs.

"Chris" <??**@nospam.dcwrote in message
news:e5**************@TK2MSFTNGP03.phx.gbl...
>>Hi,

It's true but it doesn't matter, i thing ... it's not case sensitive
(VB.net) (i tried with both lower and uppercase).
Still same error.
"Stephany Young" <noone@localhostschreef in bericht
news:%2****************@TK2MSFTNGP02.phx.gbl.. .
In the masterpage, the id of the control is Lkred and not lkred.

mpg.FindControl("lkred") returns nothing becuase it should be
mpg.FindControl("Lkred")

"Chris" <??**@nospam.dcwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl. ..
Hi, thanks to you too. i did what you told me:but i still have the
same error for the same line "'If mpg.FindControl("lkred").Visible =
True Then'.
I show you the whole code to be sure ...(i also tried with Protected
Sub Page_Load instead of Protected Sub Page_Init).
>
>
masterpage:
-----------
<head runat="server">
<link runat="server" id="Lkred" href="App_Themes/red/red.css"
rel=Stylesheet type="text/css" visible="true"/>
<link runat="server" id="lkgreen" href="App_Themes/green/green.css"
rel=Stylesheet type="text/css" visible="false" />
</head>
>
classe:
-------
Imports Microsoft.VisualBasic
>
Public Class loginkl
Public Sub logkl()
Dim pg As New Page
Dim foo As New MasterPage
Dim mpg As MasterPage = foo
If pg.User.Identity.IsAuthenticated = True Then
If mpg.FindControl("lkred").Visible = True Then
mpg.FindControl("lkred").Visible = False
mpg.FindControl("lkgreen").Visible = True
Else
mpg.FindControl("lkred").Visible = True
mpg.FindControl("lkgreen").Visible = False
End If
End If
End Sub
End Class
>
code-behind of masterpage:
---------------------------
Partial Class MasterPage
Inherits System.Web.UI.MasterPage
Protected Sub Page_Init(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Init
Dim lg As New loginkl
lg.logkl()
End Sub
End Class
>



Mar 8 '07 #18

P: n/a
Scott,

It is something I have tried in past and I don't do it again.
The same code gave errors in windowsforms and was eaten by AspNet.
I found it very strange.

If you don't believe me, does not matter for me, it you keeps you on the
rule than you will never see it.

Cor

"Scott M." <s-***@nospam.nospamschreef in bericht
news:Ok**************@TK2MSFTNGP02.phx.gbl...
>I don't think so Cor,

A string literal is always just that.

You may be referring to situations when you refer to a field name in a
database using a case that does not match the capitalization of the actual
field name.

For example, assume the following SQL statement:

SELECT * From tblCustomers WHERE NAME = "Smith"

It's up to the engine interpreting the strings to decide if it wishes to
enforce case-sensitivity. Many databases do not enforce it on field
names, but do enforce it when querying on a particular value (the WHERE
clause of a SQL statement). In other words, if the field name or string
in the WHERE clause isn't treated case-sensitively, it's because the
database engine processing the SQL statement did it that way, not because
the language the SQL statement was part of (VB.NET, C#, etc.) isn't
case-sensitive.

-Scott

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:ee*************@TK2MSFTNGP04.phx.gbl...
>Scott,

Your message should be true, however, it is not always, it is strange
enough that in AspNet the string literals from ADONET can be mixed uper
and lower case. (I thought I had seen this in version 1.1).

Cor

"Scott M." <s-***@nospam.nospamschreef in bericht
news:uy**************@TK2MSFTNGP05.phx.gbl...
>>When dealing with string literals (any value in quotes), case always
matters. It's not a VB thing.

For example:

"Scott" does not equal "scott", so:

Dim A As String = "Scott"
Bim B As String = "scott"

If A = B Then
MessageBox(A & "= " & B)
Else
MessageBox(A & " <" & B)
End If

You will find that the code in the Else always runs.

"Chris" <??**@nospam.dcwrote in message
news:e5**************@TK2MSFTNGP03.phx.gbl...
Hi,

It's true but it doesn't matter, i thing ... it's not case sensitive
(VB.net) (i tried with both lower and uppercase).
Still same error.
"Stephany Young" <noone@localhostschreef in bericht
news:%2****************@TK2MSFTNGP02.phx.gbl. ..
In the masterpage, the id of the control is Lkred and not lkred.
>
mpg.FindControl("lkred") returns nothing becuase it should be
mpg.FindControl("Lkred")
>
>
>
"Chris" <??**@nospam.dcwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl.. .
>Hi, thanks to you too. i did what you told me:but i still have the
>same error for the same line "'If mpg.FindControl("lkred").Visible =
>True Then'.
>I show you the whole code to be sure ...(i also tried with Protected
>Sub Page_Load instead of Protected Sub Page_Init).
>>
>>
>masterpage:
>-----------
><head runat="server">
> <link runat="server" id="Lkred" href="App_Themes/red/red.css"
>rel=Stylesheet type="text/css" visible="true"/>
> <link runat="server" id="lkgreen" href="App_Themes/green/green.css"
>rel=Stylesheet type="text/css" visible="false" />
> </head>
>>
>classe:
>-------
>Imports Microsoft.VisualBasic
>>
>Public Class loginkl
> Public Sub logkl()
> Dim pg As New Page
> Dim foo As New MasterPage
> Dim mpg As MasterPage = foo
> If pg.User.Identity.IsAuthenticated = True Then
> If mpg.FindControl("lkred").Visible = True Then
> mpg.FindControl("lkred").Visible = False
> mpg.FindControl("lkgreen").Visible = True
> Else
> mpg.FindControl("lkred").Visible = True
> mpg.FindControl("lkgreen").Visible = False
> End If
> End If
> End Sub
>End Class
>>
>code-behind of masterpage:
>---------------------------
>Partial Class MasterPage
> Inherits System.Web.UI.MasterPage
> Protected Sub Page_Init(ByVal sender As Object, ByVal e As
>System.EventArgs) Handles Me.Init
> Dim lg As New loginkl
> lg.logkl()
> End Sub
>End Class
>>
>




Mar 9 '07 #19

P: n/a
Cor, you haven't given any specific example of "something I have tried in
the past", so I can't really speak to it.

The fact is that VB.NET strings ARE case-sensitive, always. This is not to
say that every class treats strings case-sensitively. It's that old
discussion about the difference between the Framework and the language.

As you know, strings are reference types (objects) and so, they are
instanced and stored on the heap. Each string is a different object (with
the exception of interned strings - - different topic) and we are not
talking about evaluating if one string object "IS" the same as another. We
are talking about the value of one string being equivellant to another. To
the CLR, the char "S" is not equivellant to the char "s" - that doesn't
change, ever.

Now, could you run into a class that takes a string as an input value in one
of its methods and could that method deal with that string in a non
case-sensitive way? Sure, but that is a very different thing from saying
that VB.NET strings are not case-sensitive, which is what Chris said:

" it's not case sensitive (VB.net)"
-Scott


"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:e0*************@TK2MSFTNGP06.phx.gbl...
Scott,

It is something I have tried in past and I don't do it again.
The same code gave errors in windowsforms and was eaten by AspNet.
I found it very strange.

If you don't believe me, does not matter for me, it you keeps you on the
rule than you will never see it.

Cor

"Scott M." <s-***@nospam.nospamschreef in bericht
news:Ok**************@TK2MSFTNGP02.phx.gbl...
>>I don't think so Cor,

A string literal is always just that.

You may be referring to situations when you refer to a field name in a
database using a case that does not match the capitalization of the
actual field name.

For example, assume the following SQL statement:

SELECT * From tblCustomers WHERE NAME = "Smith"

It's up to the engine interpreting the strings to decide if it wishes to
enforce case-sensitivity. Many databases do not enforce it on field
names, but do enforce it when querying on a particular value (the WHERE
clause of a SQL statement). In other words, if the field name or string
in the WHERE clause isn't treated case-sensitively, it's because the
database engine processing the SQL statement did it that way, not because
the language the SQL statement was part of (VB.NET, C#, etc.) isn't
case-sensitive.

-Scott

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:ee*************@TK2MSFTNGP04.phx.gbl...
>>Scott,

Your message should be true, however, it is not always, it is strange
enough that in AspNet the string literals from ADONET can be mixed uper
and lower case. (I thought I had seen this in version 1.1).

Cor

"Scott M." <s-***@nospam.nospamschreef in bericht
news:uy**************@TK2MSFTNGP05.phx.gbl...
When dealing with string literals (any value in quotes), case always
matters. It's not a VB thing.

For example:

"Scott" does not equal "scott", so:

Dim A As String = "Scott"
Bim B As String = "scott"

If A = B Then
MessageBox(A & "= " & B)
Else
MessageBox(A & " <" & B)
End If

You will find that the code in the Else always runs.

"Chris" <??**@nospam.dcwrote in message
news:e5**************@TK2MSFTNGP03.phx.gbl...
Hi,
>
It's true but it doesn't matter, i thing ... it's not case sensitive
(VB.net) (i tried with both lower and uppercase).
Still same error.
>
>
"Stephany Young" <noone@localhostschreef in bericht
news:%2****************@TK2MSFTNGP02.phx.gbl.. .
>In the masterpage, the id of the control is Lkred and not lkred.
>>
>mpg.FindControl("lkred") returns nothing becuase it should be
>mpg.FindControl("Lkred")
>>
>>
>>
>"Chris" <??**@nospam.dcwrote in message
>news:%2****************@TK2MSFTNGP06.phx.gbl. ..
>>Hi, thanks to you too. i did what you told me:but i still have the
>>same error for the same line "'If mpg.FindControl("lkred").Visible =
>>True Then'.
>>I show you the whole code to be sure ...(i also tried with Protected
>>Sub Page_Load instead of Protected Sub Page_Init).
>>>
>>>
>>masterpage:
>>-----------
>><head runat="server">
>> <link runat="server" id="Lkred" href="App_Themes/red/red.css"
>>rel=Stylesheet type="text/css" visible="true"/>
>> <link runat="server" id="lkgreen" href="App_Themes/green/green.css"
>>rel=Stylesheet type="text/css" visible="false" />
>> </head>
>>>
>>classe:
>>-------
>>Imports Microsoft.VisualBasic
>>>
>>Public Class loginkl
>> Public Sub logkl()
>> Dim pg As New Page
>> Dim foo As New MasterPage
>> Dim mpg As MasterPage = foo
>> If pg.User.Identity.IsAuthenticated = True Then
>> If mpg.FindControl("lkred").Visible = True Then
>> mpg.FindControl("lkred").Visible = False
>> mpg.FindControl("lkgreen").Visible = True
>> Else
>> mpg.FindControl("lkred").Visible = True
>> mpg.FindControl("lkgreen").Visible = False
>> End If
>> End If
>> End Sub
>>End Class
>>>
>>code-behind of masterpage:
>>---------------------------
>>Partial Class MasterPage
>> Inherits System.Web.UI.MasterPage
>> Protected Sub Page_Init(ByVal sender As Object, ByVal e As
>>System.EventArgs) Handles Me.Init
>> Dim lg As New loginkl
>> lg.logkl()
>> End Sub
>>End Class
>>>
>>
>
>




Mar 9 '07 #20

P: n/a
No scott I am not talking about that.

I had the expirience that in ASPNET this was happening

Select MyField from X.

In Windowsform I "had to" (must) use this when using a non strongly typed
datatable

dim myfield as string = thedatatable.rows(0)("MyField")

in ASPX i could use it as
dim myfield as string = thedatatable.rows(0)("mYfIELD")

You understand that I was confused about that. It was in 1.1

Cor

"Scott M." <s-***@nospam.nospamschreef in bericht
news:ur**************@TK2MSFTNGP04.phx.gbl...
Cor, you haven't given any specific example of "something I have tried in
the past", so I can't really speak to it.

The fact is that VB.NET strings ARE case-sensitive, always. This is not
to say that every class treats strings case-sensitively. It's that old
discussion about the difference between the Framework and the language.

As you know, strings are reference types (objects) and so, they are
instanced and stored on the heap. Each string is a different object (with
the exception of interned strings - - different topic) and we are not
talking about evaluating if one string object "IS" the same as another.
We are talking about the value of one string being equivellant to another.
To the CLR, the char "S" is not equivellant to the char "s" - that doesn't
change, ever.

Now, could you run into a class that takes a string as an input value in
one of its methods and could that method deal with that string in a non
case-sensitive way? Sure, but that is a very different thing from saying
that VB.NET strings are not case-sensitive, which is what Chris said:

" it's not case sensitive (VB.net)"
-Scott


"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:e0*************@TK2MSFTNGP06.phx.gbl...
>Scott,

It is something I have tried in past and I don't do it again.
The same code gave errors in windowsforms and was eaten by AspNet.
I found it very strange.

If you don't believe me, does not matter for me, it you keeps you on the
rule than you will never see it.

Cor

"Scott M." <s-***@nospam.nospamschreef in bericht
news:Ok**************@TK2MSFTNGP02.phx.gbl...
>>>I don't think so Cor,

A string literal is always just that.

You may be referring to situations when you refer to a field name in a
database using a case that does not match the capitalization of the
actual field name.

For example, assume the following SQL statement:

SELECT * From tblCustomers WHERE NAME = "Smith"

It's up to the engine interpreting the strings to decide if it wishes to
enforce case-sensitivity. Many databases do not enforce it on field
names, but do enforce it when querying on a particular value (the WHERE
clause of a SQL statement). In other words, if the field name or string
in the WHERE clause isn't treated case-sensitively, it's because the
database engine processing the SQL statement did it that way, not
because the language the SQL statement was part of (VB.NET, C#, etc.)
isn't case-sensitive.

-Scott

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:ee*************@TK2MSFTNGP04.phx.gbl...
Scott,

Your message should be true, however, it is not always, it is strange
enough that in AspNet the string literals from ADONET can be mixed uper
and lower case. (I thought I had seen this in version 1.1).

Cor

"Scott M." <s-***@nospam.nospamschreef in bericht
news:uy**************@TK2MSFTNGP05.phx.gbl...
When dealing with string literals (any value in quotes), case always
matters. It's not a VB thing.
>
For example:
>
"Scott" does not equal "scott", so:
>
Dim A As String = "Scott"
Bim B As String = "scott"
>
If A = B Then
MessageBox(A & "= " & B)
Else
MessageBox(A & " <" & B)
End If
>
You will find that the code in the Else always runs.
>
>
>
"Chris" <??**@nospam.dcwrote in message
news:e5**************@TK2MSFTNGP03.phx.gbl.. .
>Hi,
>>
>It's true but it doesn't matter, i thing ... it's not case sensitive
>(VB.net) (i tried with both lower and uppercase).
>Still same error.
>>
>>
>"Stephany Young" <noone@localhostschreef in bericht
>news:%2****************@TK2MSFTNGP02.phx.gbl. ..
>>In the masterpage, the id of the control is Lkred and not lkred.
>>>
>>mpg.FindControl("lkred") returns nothing becuase it should be
>>mpg.FindControl("Lkred")
>>>
>>>
>>>
>>"Chris" <??**@nospam.dcwrote in message
>>news:%2****************@TK2MSFTNGP06.phx.gbl ...
>>>Hi, thanks to you too. i did what you told me:but i still have the
>>>same error for the same line "'If mpg.FindControl("lkred").Visible
>>>= True Then'.
>>>I show you the whole code to be sure ...(i also tried with
>>>Protected Sub Page_Load instead of Protected Sub Page_Init).
>>>>
>>>>
>>>masterpage:
>>>-----------
>>><head runat="server">
>>> <link runat="server" id="Lkred" href="App_Themes/red/red.css"
>>>rel=Stylesheet type="text/css" visible="true"/>
>>> <link runat="server" id="lkgreen"
>>>href="App_Themes/green/green.css" rel=Stylesheet type="text/css"
>>>visible="false" />
>>> </head>
>>>>
>>>classe:
>>>-------
>>>Imports Microsoft.VisualBasic
>>>>
>>>Public Class loginkl
>>> Public Sub logkl()
>>> Dim pg As New Page
>>> Dim foo As New MasterPage
>>> Dim mpg As MasterPage = foo
>>> If pg.User.Identity.IsAuthenticated = True Then
>>> If mpg.FindControl("lkred").Visible = True Then
>>> mpg.FindControl("lkred").Visible = False
>>> mpg.FindControl("lkgreen").Visible = True
>>> Else
>>> mpg.FindControl("lkred").Visible = True
>>> mpg.FindControl("lkgreen").Visible = False
>>> End If
>>> End If
>>> End Sub
>>>End Class
>>>>
>>>code-behind of masterpage:
>>>---------------------------
>>>Partial Class MasterPage
>>> Inherits System.Web.UI.MasterPage
>>> Protected Sub Page_Init(ByVal sender As Object, ByVal e As
>>>System.EventArgs) Handles Me.Init
>>> Dim lg As New loginkl
>>> lg.logkl()
>>> End Sub
>>>End Class
>>>>
>>>
>>
>>
>
>




Mar 9 '07 #21

P: n/a
Cor, this is exactly what I'm describing. I'm not sure why you say you
aren't talking about that.

In your two examples:
dim myfield as string = thedatatable.rows(0)("MyField")

in ASPX i could use it as
dim myfield as string = thedatatable.rows(0)("mYfIELD")
You are passing a string into an indexed property. As you yourself point
out, one example is passing it to a DIFFERENT TYPE than the other. It is
the TYPE that is or isn't enforcing the case-sensitivity, not the VB.NET
language.

You see the difference? There's nothing about your example that would make
the statement: " it's not case sensitive (VB.net)" a true one.

-Scott


"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:OK**************@TK2MSFTNGP03.phx.gbl...
No scott I am not talking about that.

I had the expirience that in ASPNET this was happening

Select MyField from X.

In Windowsform I "had to" (must) use this when using a non strongly typed
datatable

dim myfield as string = thedatatable.rows(0)("MyField")

in ASPX i could use it as
dim myfield as string = thedatatable.rows(0)("mYfIELD")

You understand that I was confused about that. It was in 1.1

Cor

"Scott M." <s-***@nospam.nospamschreef in bericht
news:ur**************@TK2MSFTNGP04.phx.gbl...
>Cor, you haven't given any specific example of "something I have tried in
the past", so I can't really speak to it.

The fact is that VB.NET strings ARE case-sensitive, always. This is not
to say that every class treats strings case-sensitively. It's that old
discussion about the difference between the Framework and the language.

As you know, strings are reference types (objects) and so, they are
instanced and stored on the heap. Each string is a different object
(with the exception of interned strings - - different topic) and we are
not talking about evaluating if one string object "IS" the same as
another. We are talking about the value of one string being equivellant
to another. To the CLR, the char "S" is not equivellant to the char "s" -
that doesn't change, ever.

Now, could you run into a class that takes a string as an input value in
one of its methods and could that method deal with that string in a non
case-sensitive way? Sure, but that is a very different thing from saying
that VB.NET strings are not case-sensitive, which is what Chris said:

" it's not case sensitive (VB.net)"
-Scott


"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:e0*************@TK2MSFTNGP06.phx.gbl...
>>Scott,

It is something I have tried in past and I don't do it again.
The same code gave errors in windowsforms and was eaten by AspNet.
I found it very strange.

If you don't believe me, does not matter for me, it you keeps you on the
rule than you will never see it.

Cor

"Scott M." <s-***@nospam.nospamschreef in bericht
news:Ok**************@TK2MSFTNGP02.phx.gbl...
I don't think so Cor,

A string literal is always just that.

You may be referring to situations when you refer to a field name in a
database using a case that does not match the capitalization of the
actual field name.

For example, assume the following SQL statement:

SELECT * From tblCustomers WHERE NAME = "Smith"

It's up to the engine interpreting the strings to decide if it wishes
to enforce case-sensitivity. Many databases do not enforce it on field
names, but do enforce it when querying on a particular value (the WHERE
clause of a SQL statement). In other words, if the field name or
string in the WHERE clause isn't treated case-sensitively, it's because
the database engine processing the SQL statement did it that way, not
because the language the SQL statement was part of (VB.NET, C#, etc.)
isn't case-sensitive.

-Scott

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:ee*************@TK2MSFTNGP04.phx.gbl...
Scott,
>
Your message should be true, however, it is not always, it is strange
enough that in AspNet the string literals from ADONET can be mixed
uper and lower case. (I thought I had seen this in version 1.1).
>
Cor
>
"Scott M." <s-***@nospam.nospamschreef in bericht
news:uy**************@TK2MSFTNGP05.phx.gbl.. .
>When dealing with string literals (any value in quotes), case always
>matters. It's not a VB thing.
>>
>For example:
>>
>"Scott" does not equal "scott", so:
>>
>Dim A As String = "Scott"
>Bim B As String = "scott"
>>
>If A = B Then
> MessageBox(A & "= " & B)
>Else
> MessageBox(A & " <" & B)
>End If
>>
>You will find that the code in the Else always runs.
>>
>>
>>
>"Chris" <??**@nospam.dcwrote in message
>news:e5**************@TK2MSFTNGP03.phx.gbl. ..
>>Hi,
>>>
>>It's true but it doesn't matter, i thing ... it's not case sensitive
>>(VB.net) (i tried with both lower and uppercase).
>>Still same error.
>>>
>>>
>>"Stephany Young" <noone@localhostschreef in bericht
>>news:%2****************@TK2MSFTNGP02.phx.gbl ...
>>>In the masterpage, the id of the control is Lkred and not lkred.
>>>>
>>>mpg.FindControl("lkred") returns nothing becuase it should be
>>>mpg.FindControl("Lkred")
>>>>
>>>>
>>>>
>>>"Chris" <??**@nospam.dcwrote in message
>>>news:%2****************@TK2MSFTNGP06.phx.gb l...
>>>>Hi, thanks to you too. i did what you told me:but i still have the
>>>>same error for the same line "'If mpg.FindControl("lkred").Visible
>>>>= True Then'.
>>>>I show you the whole code to be sure ...(i also tried with
>>>>Protected Sub Page_Load instead of Protected Sub Page_Init).
>>>>>
>>>>>
>>>>masterpage:
>>>>-----------
>>>><head runat="server">
>>>> <link runat="server" id="Lkred" href="App_Themes/red/red.css"
>>>>rel=Stylesheet type="text/css" visible="true"/>
>>>> <link runat="server" id="lkgreen"
>>>>href="App_Themes/green/green.css" rel=Stylesheet type="text/css"
>>>>visible="false" />
>>>> </head>
>>>>>
>>>>classe:
>>>>-------
>>>>Imports Microsoft.VisualBasic
>>>>>
>>>>Public Class loginkl
>>>> Public Sub logkl()
>>>> Dim pg As New Page
>>>> Dim foo As New MasterPage
>>>> Dim mpg As MasterPage = foo
>>>> If pg.User.Identity.IsAuthenticated = True Then
>>>> If mpg.FindControl("lkred").Visible = True Then
>>>> mpg.FindControl("lkred").Visible = False
>>>> mpg.FindControl("lkgreen").Visible = True
>>>> Else
>>>> mpg.FindControl("lkred").Visible = True
>>>> mpg.FindControl("lkgreen").Visible = False
>>>> End If
>>>> End If
>>>> End Sub
>>>>End Class
>>>>>
>>>>code-behind of masterpage:
>>>>---------------------------
>>>>Partial Class MasterPage
>>>> Inherits System.Web.UI.MasterPage
>>>> Protected Sub Page_Init(ByVal sender As Object, ByVal e As
>>>>System.EventArgs) Handles Me.Init
>>>> Dim lg As New loginkl
>>>> lg.logkl()
>>>> End Sub
>>>>End Class
>>>>>
>>>>
>>>
>>>
>>
>>
>
>




Mar 9 '07 #22

P: n/a
Scott,

What different type, they are both of the type object?
(it are DataRow Items) which have an index in the column object.

It seems that ASPNET was doing an extra job by setting those columnnames to
upper or lower case, probably as they are more bound to SQL, where the
expressions are as well not case sensitive.

Cor

"Scott M." <s-***@nospam.nospamschreef in bericht
news:uu****************@TK2MSFTNGP04.phx.gbl...
Cor, this is exactly what I'm describing. I'm not sure why you say you
aren't talking about that.

In your two examples:
>dim myfield as string = thedatatable.rows(0)("MyField")

in ASPX i could use it as
dim myfield as string = thedatatable.rows(0)("mYfIELD")

You are passing a string into an indexed property. As you yourself point
out, one example is passing it to a DIFFERENT TYPE than the other. It is
the TYPE that is or isn't enforcing the case-sensitivity, not the VB.NET
language.

You see the difference? There's nothing about your example that would
make the statement: " it's not case sensitive (VB.net)" a true one.

-Scott


"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:OK**************@TK2MSFTNGP03.phx.gbl...
>No scott I am not talking about that.

I had the expirience that in ASPNET this was happening

Select MyField from X.

In Windowsform I "had to" (must) use this when using a non strongly typed
datatable

dim myfield as string = thedatatable.rows(0)("MyField")

in ASPX i could use it as
dim myfield as string = thedatatable.rows(0)("mYfIELD")

You understand that I was confused about that. It was in 1.1

Cor

"Scott M." <s-***@nospam.nospamschreef in bericht
news:ur**************@TK2MSFTNGP04.phx.gbl...
>>Cor, you haven't given any specific example of "something I have tried
in the past", so I can't really speak to it.

The fact is that VB.NET strings ARE case-sensitive, always. This is not
to say that every class treats strings case-sensitively. It's that old
discussion about the difference between the Framework and the language.

As you know, strings are reference types (objects) and so, they are
instanced and stored on the heap. Each string is a different object
(with the exception of interned strings - - different topic) and we are
not talking about evaluating if one string object "IS" the same as
another. We are talking about the value of one string being equivellant
to another. To the CLR, the char "S" is not equivellant to the char
"s" - that doesn't change, ever.

Now, could you run into a class that takes a string as an input value in
one of its methods and could that method deal with that string in a non
case-sensitive way? Sure, but that is a very different thing from
saying that VB.NET strings are not case-sensitive, which is what Chris
said:

" it's not case sensitive (VB.net)"
-Scott


"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:e0*************@TK2MSFTNGP06.phx.gbl...
Scott,

It is something I have tried in past and I don't do it again.
The same code gave errors in windowsforms and was eaten by AspNet.
I found it very strange.

If you don't believe me, does not matter for me, it you keeps you on
the rule than you will never see it.

Cor

"Scott M." <s-***@nospam.nospamschreef in bericht
news:Ok**************@TK2MSFTNGP02.phx.gbl...
>I don't think so Cor,
>
A string literal is always just that.
>
You may be referring to situations when you refer to a field name in a
database using a case that does not match the capitalization of the
actual field name.
>
For example, assume the following SQL statement:
>
SELECT * From tblCustomers WHERE NAME = "Smith"
>
It's up to the engine interpreting the strings to decide if it wishes
to enforce case-sensitivity. Many databases do not enforce it on
field names, but do enforce it when querying on a particular value
(the WHERE clause of a SQL statement). In other words, if the field
name or string in the WHERE clause isn't treated case-sensitively,
it's because the database engine processing the SQL statement did it
that way, not because the language the SQL statement was part of
(VB.NET, C#, etc.) isn't case-sensitive.
>
-Scott
>
>
>
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:ee*************@TK2MSFTNGP04.phx.gbl...
>Scott,
>>
>Your message should be true, however, it is not always, it is strange
>enough that in AspNet the string literals from ADONET can be mixed
>uper and lower case. (I thought I had seen this in version 1.1).
>>
>Cor
>>
>"Scott M." <s-***@nospam.nospamschreef in bericht
>news:uy**************@TK2MSFTNGP05.phx.gbl. ..
>>When dealing with string literals (any value in quotes), case always
>>matters. It's not a VB thing.
>>>
>>For example:
>>>
>>"Scott" does not equal "scott", so:
>>>
>>Dim A As String = "Scott"
>>Bim B As String = "scott"
>>>
>>If A = B Then
>> MessageBox(A & "= " & B)
>>Else
>> MessageBox(A & " <" & B)
>>End If
>>>
>>You will find that the code in the Else always runs.
>>>
>>>
>>>
>>"Chris" <??**@nospam.dcwrote in message
>>news:e5**************@TK2MSFTNGP03.phx.gbl.. .
>>>Hi,
>>>>
>>>It's true but it doesn't matter, i thing ... it's not case
>>>sensitive (VB.net) (i tried with both lower and uppercase).
>>>Still same error.
>>>>
>>>>
>>>"Stephany Young" <noone@localhostschreef in bericht
>>>news:%2****************@TK2MSFTNGP02.phx.gb l...
>>>>In the masterpage, the id of the control is Lkred and not lkred.
>>>>>
>>>>mpg.FindControl("lkred") returns nothing becuase it should be
>>>>mpg.FindControl("Lkred")
>>>>>
>>>>>
>>>>>
>>>>"Chris" <??**@nospam.dcwrote in message
>>>>news:%2****************@TK2MSFTNGP06.phx.g bl...
>>>>>Hi, thanks to you too. i did what you told me:but i still have
>>>>>the same error for the same line "'If
>>>>>mpg.FindControl("lkred").Visible = True Then'.
>>>>>I show you the whole code to be sure ...(i also tried with
>>>>>Protected Sub Page_Load instead of Protected Sub Page_Init).
>>>>>>
>>>>>>
>>>>>masterpage:
>>>>>-----------
>>>>><head runat="server">
>>>>> <link runat="server" id="Lkred" href="App_Themes/red/red.css"
>>>>>rel=Stylesheet type="text/css" visible="true"/>
>>>>> <link runat="server" id="lkgreen"
>>>>>href="App_Themes/green/green.css" rel=Stylesheet type="text/css"
>>>>>visible="false" />
>>>>> </head>
>>>>>>
>>>>>classe:
>>>>>-------
>>>>>Imports Microsoft.VisualBasic
>>>>>>
>>>>>Public Class loginkl
>>>>> Public Sub logkl()
>>>>> Dim pg As New Page
>>>>> Dim foo As New MasterPage
>>>>> Dim mpg As MasterPage = foo
>>>>> If pg.User.Identity.IsAuthenticated = True Then
>>>>> If mpg.FindControl("lkred").Visible = True Then
>>>>> mpg.FindControl("lkred").Visible = False
>>>>> mpg.FindControl("lkgreen").Visible = True
>>>>> Else
>>>>> mpg.FindControl("lkred").Visible = True
>>>>> mpg.FindControl("lkgreen").Visible = False
>>>>> End If
>>>>> End If
>>>>> End Sub
>>>>>End Class
>>>>>>
>>>>>code-behind of masterpage:
>>>>>---------------------------
>>>>>Partial Class MasterPage
>>>>> Inherits System.Web.UI.MasterPage
>>>>> Protected Sub Page_Init(ByVal sender As Object, ByVal e As
>>>>>System.EventArgs) Handles Me.Init
>>>>> Dim lg As New loginkl
>>>>> lg.logkl()
>>>>> End Sub
>>>>>End Class
>>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>




Mar 9 '07 #23

P: n/a
It has nothing to do with ASP.NET, since ASP.NET is nothing but a
client/server architecture that is not language dependant.

The two types you talk about are DataSet and Strongly-Typed DataSet, not
just the plain "object" type.

It's clear that Microsoft's standard DataSet requires the column name passed
as an index to the DataRow exactly as the real column name is written. But
a Strongly-Typed DataSet is a different class that inherits from DataSet,
but implements the default property of the DataRow differently. In any
case, we are talking about how the OBJECT expects the parameter, not how
VB.NET (the LANGUAGE) expects it.

Honestly Cor, I know you are smarter than your replies in this particular
topic would lead someone to believe. This is really quite simple.

"If "SCOTT" = "scott" Then" is processed by the CLR, there is no other
object involved here but the String type, so the decision as to whether the
expression is true or not is completely based on the language, which is
VB.NET, which will always return FALSE.

Your entire argument is not based on how the language would treat different
strings, you keep talking about how string data would be accepted by a type
and a type is not the same thing as a language.

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:O5**************@TK2MSFTNGP02.phx.gbl...
Scott,

What different type, they are both of the type object?
(it are DataRow Items) which have an index in the column object.

It seems that ASPNET was doing an extra job by setting those columnnames
to upper or lower case, probably as they are more bound to SQL, where the
expressions are as well not case sensitive.

Cor

"Scott M." <s-***@nospam.nospamschreef in bericht
news:uu****************@TK2MSFTNGP04.phx.gbl...
>Cor, this is exactly what I'm describing. I'm not sure why you say you
aren't talking about that.

In your two examples:
>>dim myfield as string = thedatatable.rows(0)("MyField")

in ASPX i could use it as
dim myfield as string = thedatatable.rows(0)("mYfIELD")

You are passing a string into an indexed property. As you yourself point
out, one example is passing it to a DIFFERENT TYPE than the other. It is
the TYPE that is or isn't enforcing the case-sensitivity, not the VB.NET
language.

You see the difference? There's nothing about your example that would
make the statement: " it's not case sensitive (VB.net)" a true one.

-Scott


"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:OK**************@TK2MSFTNGP03.phx.gbl...
>>No scott I am not talking about that.

I had the expirience that in ASPNET this was happening

Select MyField from X.

In Windowsform I "had to" (must) use this when using a non strongly
typed datatable

dim myfield as string = thedatatable.rows(0)("MyField")

in ASPX i could use it as
dim myfield as string = thedatatable.rows(0)("mYfIELD")

You understand that I was confused about that. It was in 1.1

Cor

"Scott M." <s-***@nospam.nospamschreef in bericht
news:ur**************@TK2MSFTNGP04.phx.gbl...
Cor, you haven't given any specific example of "something I have tried
in the past", so I can't really speak to it.

The fact is that VB.NET strings ARE case-sensitive, always. This is
not to say that every class treats strings case-sensitively. It's that
old discussion about the difference between the Framework and the
language.

As you know, strings are reference types (objects) and so, they are
instanced and stored on the heap. Each string is a different object
(with the exception of interned strings - - different topic) and we are
not talking about evaluating if one string object "IS" the same as
another. We are talking about the value of one string being equivellant
to another. To the CLR, the char "S" is not equivellant to the char
"s" - that doesn't change, ever.

Now, could you run into a class that takes a string as an input value
in one of its methods and could that method deal with that string in a
non case-sensitive way? Sure, but that is a very different thing from
saying that VB.NET strings are not case-sensitive, which is what Chris
said:

" it's not case sensitive (VB.net)"
-Scott


"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:e0*************@TK2MSFTNGP06.phx.gbl...
Scott,
>
It is something I have tried in past and I don't do it again.
The same code gave errors in windowsforms and was eaten by AspNet.
I found it very strange.
>
If you don't believe me, does not matter for me, it you keeps you on
the rule than you will never see it.
>
Cor
>
"Scott M." <s-***@nospam.nospamschreef in bericht
news:Ok**************@TK2MSFTNGP02.phx.gbl.. .
>>I don't think so Cor,
>>
>A string literal is always just that.
>>
>You may be referring to situations when you refer to a field name in
>a database using a case that does not match the capitalization of the
>actual field name.
>>
>For example, assume the following SQL statement:
>>
>SELECT * From tblCustomers WHERE NAME = "Smith"
>>
>It's up to the engine interpreting the strings to decide if it wishes
>to enforce case-sensitivity. Many databases do not enforce it on
>field names, but do enforce it when querying on a particular value
>(the WHERE clause of a SQL statement). In other words, if the field
>name or string in the WHERE clause isn't treated case-sensitively,
>it's because the database engine processing the SQL statement did it
>that way, not because the language the SQL statement was part of
>(VB.NET, C#, etc.) isn't case-sensitive.
>>
>-Scott
>>
>>
>>
>"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
>news:ee*************@TK2MSFTNGP04.phx.gbl.. .
>>Scott,
>>>
>>Your message should be true, however, it is not always, it is
>>strange enough that in AspNet the string literals from ADONET can be
>>mixed uper and lower case. (I thought I had seen this in version
>>1.1).
>>>
>>Cor
>>>
>>"Scott M." <s-***@nospam.nospamschreef in bericht
>>news:uy**************@TK2MSFTNGP05.phx.gbl.. .
>>>When dealing with string literals (any value in quotes), case
>>>always matters. It's not a VB thing.
>>>>
>>>For example:
>>>>
>>>"Scott" does not equal "scott", so:
>>>>
>>>Dim A As String = "Scott"
>>>Bim B As String = "scott"
>>>>
>>>If A = B Then
>>> MessageBox(A & "= " & B)
>>>Else
>>> MessageBox(A & " <" & B)
>>>End If
>>>>
>>>You will find that the code in the Else always runs.
>>>>
>>>>
>>>>
>>>"Chris" <??**@nospam.dcwrote in message
>>>news:e5**************@TK2MSFTNGP03.phx.gbl. ..
>>>>Hi,
>>>>>
>>>>It's true but it doesn't matter, i thing ... it's not case
>>>>sensitive (VB.net) (i tried with both lower and uppercase).
>>>>Still same error.
>>>>>
>>>>>
>>>>"Stephany Young" <noone@localhostschreef in bericht
>>>>news:%2****************@TK2MSFTNGP02.phx.g bl...
>>>>>In the masterpage, the id of the control is Lkred and not lkred.
>>>>>>
>>>>>mpg.FindControl("lkred") returns nothing becuase it should be
>>>>>mpg.FindControl("Lkred")
>>>>>>
>>>>>>
>>>>>>
>>>>>"Chris" <??**@nospam.dcwrote in message
>>>>>news:%2****************@TK2MSFTNGP06.phx. gbl...
>>>>>>Hi, thanks to you too. i did what you told me:but i still have
>>>>>>the same error for the same line "'If
>>>>>>mpg.FindControl("lkred").Visible = True Then'.
>>>>>>I show you the whole code to be sure ...(i also tried with
>>>>>>Protected Sub Page_Load instead of Protected Sub Page_Init).
>>>>>>>
>>>>>>>
>>>>>>masterpage:
>>>>>>-----------
>>>>>><head runat="server">
>>>>>> <link runat="server" id="Lkred" href="App_Themes/red/red.css"
>>>>>>rel=Stylesheet type="text/css" visible="true"/>
>>>>>> <link runat="server" id="lkgreen"
>>>>>>href="App_Themes/green/green.css" rel=Stylesheet type="text/css"
>>>>>>visible="false" />
>>>>>> </head>
>>>>>>>
>>>>>>classe:
>>>>>>-------
>>>>>>Imports Microsoft.VisualBasic
>>>>>>>
>>>>>>Public Class loginkl
>>>>>> Public Sub logkl()
>>>>>> Dim pg As New Page
>>>>>> Dim foo As New MasterPage
>>>>>> Dim mpg As MasterPage = foo
>>>>>> If pg.User.Identity.IsAuthenticated = True Then
>>>>>> If mpg.FindControl("lkred").Visible = True Then
>>>>>> mpg.FindControl("lkred").Visible = False
>>>>>> mpg.FindControl("lkgreen").Visible = True
>>>>>> Else
>>>>>> mpg.FindControl("lkred").Visible = True
>>>>>> mpg.FindControl("lkgreen").Visible = False
>>>>>> End If
>>>>>> End If
>>>>>> End Sub
>>>>>>End Class
>>>>>>>
>>>>>>code-behind of masterpage:
>>>>>>---------------------------
>>>>>>Partial Class MasterPage
>>>>>> Inherits System.Web.UI.MasterPage
>>>>>> Protected Sub Page_Init(ByVal sender As Object, ByVal e As
>>>>>>System.EventArgs) Handles Me.Init
>>>>>> Dim lg As New loginkl
>>>>>> lg.logkl()
>>>>>> End Sub
>>>>>>End Class
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>




Mar 10 '07 #24

P: n/a
"Scott M." <s-***@nospam.nospamschrieb:
"If "SCOTT" = "scott" Then" is processed by the CLR, there is no other
object involved here but the String type, so the decision as to whether
the expression is true or not is completely based on the language, which
is VB.NET, which will always return FALSE.
This depends on 'Option Compare {Text, Binary}'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Mar 10 '07 #25

P: n/a
True, but that takes us in a different direction from the particulars at
hand.
"Herfried K. Wagner [MVP]" <hi***************@gmx.atwrote in message
news:OL**************@TK2MSFTNGP05.phx.gbl...
"Scott M." <s-***@nospam.nospamschrieb:
>"If "SCOTT" = "scott" Then" is processed by the CLR, there is no other
object involved here but the String type, so the decision as to whether
the expression is true or not is completely based on the language, which
is VB.NET, which will always return FALSE.

This depends on 'Option Compare {Text, Binary}'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Mar 10 '07 #26

P: n/a
Scott,

My message has nothing to do with the behaviour of the string.

What I am writting about is use of the string as indexer in a not strongly
typed dataset.

I was once supprised that it seems that it seems that they have made in
ASPNET somewhere an unexpected inbuild string.ToUppercase (or string to
Lowercase) around AdoNet.

That is all, with that not denying what you wrote, only that there can
sometimes be suprisses.

:-)

Cor

"Scott M." <s-***@nospam.nospamschreef in bericht
news:uu*************@TK2MSFTNGP04.phx.gbl...
True, but that takes us in a different direction from the particulars at
hand.
"Herfried K. Wagner [MVP]" <hi***************@gmx.atwrote in message
news:OL**************@TK2MSFTNGP05.phx.gbl...
>"Scott M." <s-***@nospam.nospamschrieb:
>>"If "SCOTT" = "scott" Then" is processed by the CLR, there is no other
object involved here but the String type, so the decision as to whether
the expression is true or not is completely based on the language, which
is VB.NET, which will always return FALSE.

This depends on 'Option Compare {Text, Binary}'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


Mar 10 '07 #27

P: n/a
I hear what you are saying Cor, but you are saying this in a very
mis-leading (and IMHO) incorrect way:

I have been talking all along about the VB.NET language, not how a string
can be passed to a property or method. I have been doing this because of
Chris's first comment about VB.NET not being case-sensitive.


"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:O1**************@TK2MSFTNGP05.phx.gbl...
Scott,

My message has nothing to do with the behaviour of the string.

What I am writting about is use of the string as indexer in a not strongly
typed dataset.

I was once supprised that it seems that it seems that they have made in
ASPNET somewhere an unexpected inbuild string.ToUppercase (or string to
Lowercase) around AdoNet.

That is all, with that not denying what you wrote, only that there can
sometimes be suprisses.

:-)

Cor

"Scott M." <s-***@nospam.nospamschreef in bericht
news:uu*************@TK2MSFTNGP04.phx.gbl...
>True, but that takes us in a different direction from the particulars at
hand.
"Herfried K. Wagner [MVP]" <hi***************@gmx.atwrote in message
news:OL**************@TK2MSFTNGP05.phx.gbl...
>>"Scott M." <s-***@nospam.nospamschrieb:
"If "SCOTT" = "scott" Then" is processed by the CLR, there is no other
object involved here but the String type, so the decision as to whether
the expression is true or not is completely based on the language,
which is VB.NET, which will always return FALSE.

This depends on 'Option Compare {Text, Binary}'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>



Mar 10 '07 #28

P: n/a
I think the way as you are telling it can be more misleading.

Telling that something has always the same behaviour, while there are
exceptions, can lead that somebody can search for a problem weeks. To
prevent that was the only meaning of my message.

You can answer this message but I don't answer that anymore. Not to be rude,
however because there is enough written and we both will not add new things
anymore

Cor
Mar 11 '07 #29

P: n/a
But, there aren't exceptions and that is my point. The language never
changes the way it handles strings, objects may, but the language doesn't.
To not separate the two things is right up there with those who believe the
Framework is the language and vice versa.


"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:uu**************@TK2MSFTNGP05.phx.gbl...
>I think the way as you are telling it can be more misleading.

Telling that something has always the same behaviour, while there are
exceptions, can lead that somebody can search for a problem weeks. To
prevent that was the only meaning of my message.

You can answer this message but I don't answer that anymore. Not to be
rude, however because there is enough written and we both will not add new
things anymore

Cor

Mar 11 '07 #30

P: n/a
Scott,

I told not to write anymore, however maybe does this helps in this
communication.

Maybe we are talking about different things, have a look at this tested code
and than to the word Dataset inside the session.

That it has different cases is my point, this is the same for Net.Data names
here while it is AFAIK impossible for WindowsForms to use then different
cases.

\\\\
'To test does this need a DataGrid on the page
Partial Class _Default
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim ds As System.Data.DataSet
DataGrid1.AllowPaging = True
DataGrid1.PagerStyle.Mode = PagerMode.NumericPages
DataGrid1.PageSize = 5
DataGrid1.PagerStyle.PageButtonCount = 5
If IsPostBack Then
ds = DirectCast(Session("Dataset"), System.Data.DataSet)
DataGrid1.DataSource = ds
Else
ds = New System.Data.DataSet
Dim dt As New System.Data.DataTable
dt.Columns.Add("Mycolumn")
For i As Integer = 0 To 100
dt.LoadDataRow(New Object() {i.ToString}, True)
Next
ds.Tables.Add(dt)
Session("dataSet") = ds
DataGrid1.DataSource = ds
DataBind()
End If
End Sub

Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e _
As System.Web.UI.WebControls.DataGridPageChangedEvent Args) _
Handles DataGrid1.PageIndexChanged
DataGrid1.CurrentPageIndex = e.NewPageIndex
DataGrid1.DataBind()
End Sub

End Class
///


"Scott M." <s-***@nospam.nospamschreef in bericht
news:%2******************@TK2MSFTNGP06.phx.gbl...
But, there aren't exceptions and that is my point. The language never
changes the way it handles strings, objects may, but the language doesn't.
To not separate the two things is right up there with those who believe
the Framework is the language and vice versa.


"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:uu**************@TK2MSFTNGP05.phx.gbl...
>>I think the way as you are telling it can be more misleading.

Telling that something has always the same behaviour, while there are
exceptions, can lead that somebody can search for a problem weeks. To
prevent that was the only meaning of my message.

You can answer this message but I don't answer that anymore. Not to be
rude, however because there is enough written and we both will not add
new things anymore

Cor


Mar 11 '07 #31

P: n/a
Yes Cor, we are talking about different things, that has been my point here
all along with you. You are talking about how strings can be passed to an
object and how that object requires (or doesn't require) the string to be
passed case-sensitively. I get that, we get that. But that has not been
what I have been talking about and I've repeated that fact over and over
again.

Every one of your posts in this thread are true and correct, except the
first one, which you've been debating incorrectly ever since you made it.

I have been and still am, simply pointing out that the ADO.NET classes (or
any class) may require (or not) a string to be passed in a certain way, but
that has nothing to do with how VB.NET works with strings and since this
whole branch of the thread started with "it's not case sensitive (VB.NET)",
it makes no sense to me why you keep coming back with the same example that
has nothing to do with this stattement.

You've also made references to ASP.NET not being case-sensitive, but that
statement make no sense in any conversation since ASP.NET is an
architecture, not an object, nor a language. I think you mean to say that
in ASP.NET, there are certain types that you don't use in a WinForms
application, such as the System.Web.UI.WebControls.DataGrid and the
System.Windows.Forms.DataGrid and since these are two different types, they
handle case sensitivity differently. This again, boils down to the type
differences, not ASP.NET.

It's really very simple VB.NET is not a type, it's a language. VB.NET has
its rules about how strings are handled and any given type can have its own
rules that may differ, but to say that VB.NET strings are not case-sensitve
*sometimes* and then to show an example of a string being used on a type, is
an incorrect statement to make.

You've shown code that uses strings on types, but you haven't addressed
strings used by the language. I originally showed this code in my first
example:

Dim A As String = "Scott"
Bim B As String = "scott"

If A = B Then
MessageBox(A & "= " & B)
Else
MessageBox(A & " <" & B)
End If

You will find that the code in the Else always runs.

Your response was:

"Your message should be true, however, it is not always,"

but, that is incorrect to say, the else portion will always run. You then
went on to say:

"it is strange enough
that in AspNet the string literals from ADONET can be mixed uper and lower
case. (I thought I had seen this in version 1.1)."

Which has nothing to do with VB.NET, it has to do with types.

You've made your point very clearly, you've just been labelling it
incorrectly and that's all I've been trying to point out to you.

Right comments, wrong conversation.


"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:en**************@TK2MSFTNGP02.phx.gbl...
Scott,

I told not to write anymore, however maybe does this helps in this
communication.

Maybe we are talking about different things, have a look at this tested
code and than to the word Dataset inside the session.

That it has different cases is my point, this is the same for Net.Data
names here while it is AFAIK impossible for WindowsForms to use then
different cases.

\\\\
'To test does this need a DataGrid on the page
Partial Class _Default
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim ds As System.Data.DataSet
DataGrid1.AllowPaging = True
DataGrid1.PagerStyle.Mode = PagerMode.NumericPages
DataGrid1.PageSize = 5
DataGrid1.PagerStyle.PageButtonCount = 5
If IsPostBack Then
ds = DirectCast(Session("Dataset"), System.Data.DataSet)
DataGrid1.DataSource = ds
Else
ds = New System.Data.DataSet
Dim dt As New System.Data.DataTable
dt.Columns.Add("Mycolumn")
For i As Integer = 0 To 100
dt.LoadDataRow(New Object() {i.ToString}, True)
Next
ds.Tables.Add(dt)
Session("dataSet") = ds
DataGrid1.DataSource = ds
DataBind()
End If
End Sub

Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e
_
As System.Web.UI.WebControls.DataGridPageChangedEvent Args) _
Handles DataGrid1.PageIndexChanged
DataGrid1.CurrentPageIndex = e.NewPageIndex
DataGrid1.DataBind()
End Sub

End Class
///


"Scott M." <s-***@nospam.nospamschreef in bericht
news:%2******************@TK2MSFTNGP06.phx.gbl...
>But, there aren't exceptions and that is my point. The language never
changes the way it handles strings, objects may, but the language
doesn't. To not separate the two things is right up there with those who
believe the Framework is the language and vice versa.


"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:uu**************@TK2MSFTNGP05.phx.gbl...
>>>I think the way as you are telling it can be more misleading.

Telling that something has always the same behaviour, while there are
exceptions, can lead that somebody can search for a problem weeks. To
prevent that was the only meaning of my message.

You can answer this message but I don't answer that anymore. Not to be
rude, however because there is enough written and we both will not add
new things anymore

Cor



Mar 11 '07 #32

P: n/a
Scott,

Are you sure of that, my replies were based on your reply on Chris who was
denying this in a way.

"Stephany Young"
In the masterpage, the id of the control is Lkred and not lkred.

mpg.FindControl("lkred") returns nothing becuase it should be
mpg.FindControl("Lkred")
I am not saying that the message from Stephany is wrong there was my answer
not about.

Cor

"Scott M." <s-***@nospam.nospamschreef in bericht
news:%2****************@TK2MSFTNGP05.phx.gbl...
Yes Cor, we are talking about different things, that has been my point
here all along with you. You are talking about how strings can be passed
to an object and how that object requires (or doesn't require) the string
to be passed case-sensitively. I get that, we get that. But that has not
been what I have been talking about and I've repeated that fact over and
over again.

Every one of your posts in this thread are true and correct, except the
first one, which you've been debating incorrectly ever since you made it.

I have been and still am, simply pointing out that the ADO.NET classes (or
any class) may require (or not) a string to be passed in a certain way,
but that has nothing to do with how VB.NET works with strings and since
this whole branch of the thread started with "it's not case sensitive
(VB.NET)", it makes no sense to me why you keep coming back with the same
example that has nothing to do with this stattement.

You've also made references to ASP.NET not being case-sensitive, but that
statement make no sense in any conversation since ASP.NET is an
architecture, not an object, nor a language. I think you mean to say that
in ASP.NET, there are certain types that you don't use in a WinForms
application, such as the System.Web.UI.WebControls.DataGrid and the
System.Windows.Forms.DataGrid and since these are two different types,
they handle case sensitivity differently. This again, boils down to the
type differences, not ASP.NET.

It's really very simple VB.NET is not a type, it's a language. VB.NET has
its rules about how strings are handled and any given type can have its
own rules that may differ, but to say that VB.NET strings are not
case-sensitve *sometimes* and then to show an example of a string being
used on a type, is an incorrect statement to make.

You've shown code that uses strings on types, but you haven't addressed
strings used by the language. I originally showed this code in my first
example:

Dim A As String = "Scott"
Bim B As String = "scott"

If A = B Then
MessageBox(A & "= " & B)
Else
MessageBox(A & " <" & B)
End If

You will find that the code in the Else always runs.

Your response was:

"Your message should be true, however, it is not always,"

but, that is incorrect to say, the else portion will always run. You then
went on to say:

"it is strange enough
that in AspNet the string literals from ADONET can be mixed uper and lower
case. (I thought I had seen this in version 1.1)."

Which has nothing to do with VB.NET, it has to do with types.

You've made your point very clearly, you've just been labelling it
incorrectly and that's all I've been trying to point out to you.

Right comments, wrong conversation.


"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:en**************@TK2MSFTNGP02.phx.gbl...
>Scott,

I told not to write anymore, however maybe does this helps in this
communication.

Maybe we are talking about different things, have a look at this tested
code and than to the word Dataset inside the session.

That it has different cases is my point, this is the same for Net.Data
names here while it is AFAIK impossible for WindowsForms to use then
different cases.

\\\\
'To test does this need a DataGrid on the page
Partial Class _Default
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim ds As System.Data.DataSet
DataGrid1.AllowPaging = True
DataGrid1.PagerStyle.Mode = PagerMode.NumericPages
DataGrid1.PageSize = 5
DataGrid1.PagerStyle.PageButtonCount = 5
If IsPostBack Then
ds = DirectCast(Session("Dataset"), System.Data.DataSet)
DataGrid1.DataSource = ds
Else
ds = New System.Data.DataSet
Dim dt As New System.Data.DataTable
dt.Columns.Add("Mycolumn")
For i As Integer = 0 To 100
dt.LoadDataRow(New Object() {i.ToString}, True)
Next
ds.Tables.Add(dt)
Session("dataSet") = ds
DataGrid1.DataSource = ds
DataBind()
End If
End Sub

Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e
_
As System.Web.UI.WebControls.DataGridPageChangedEvent Args) _
Handles DataGrid1.PageIndexChanged
DataGrid1.CurrentPageIndex = e.NewPageIndex
DataGrid1.DataBind()
End Sub

End Class
///


"Scott M." <s-***@nospam.nospamschreef in bericht
news:%2******************@TK2MSFTNGP06.phx.gbl. ..
>>But, there aren't exceptions and that is my point. The language never
changes the way it handles strings, objects may, but the language
doesn't. To not separate the two things is right up there with those who
believe the Framework is the language and vice versa.


"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:uu**************@TK2MSFTNGP05.phx.gbl...
I think the way as you are telling it can be more misleading.

Telling that something has always the same behaviour, while there are
exceptions, can lead that somebody can search for a problem weeks. To
prevent that was the only meaning of my message.

You can answer this message but I don't answer that anymore. Not to be
rude, however because there is enough written and we both will not add
new things anymore

Cor



Mar 11 '07 #33

P: n/a
Scott,

"Scott M." <s-***@nospam.nospamschrieb:
You've shown code that uses strings on types, but you haven't addressed
strings used by the language. I originally showed this code in my first
example:

Dim A As String = "Scott"
Bim B As String = "scott"

If A = B Then
MessageBox(A & "= " & B)
Else
MessageBox(A & " <" & B)
End If

You will find that the code in the Else always runs.
Again, only with 'Option Compare Binary' (the default) set, but not when
'Option Compare Text' is used.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Mar 11 '07 #34

P: n/a
Cor,

I was not referring to Chris's mpg.FindControl issue at all. I was (as
pointed out repeatedly) referring to his statement "it's not case sensitive
(VB.NET)".

-Scott

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
Scott,

Are you sure of that, my replies were based on your reply on Chris who was
denying this in a way.

"Stephany Young"
>In the masterpage, the id of the control is Lkred and not lkred.

mpg.FindControl("lkred") returns nothing becuase it should be
mpg.FindControl("Lkred")

I am not saying that the message from Stephany is wrong there was my
answer not about.

Cor

"Scott M." <s-***@nospam.nospamschreef in bericht
news:%2****************@TK2MSFTNGP05.phx.gbl...
>Yes Cor, we are talking about different things, that has been my point
here all along with you. You are talking about how strings can be passed
to an object and how that object requires (or doesn't require) the string
to be passed case-sensitively. I get that, we get that. But that has
not been what I have been talking about and I've repeated that fact over
and over again.

Every one of your posts in this thread are true and correct, except the
first one, which you've been debating incorrectly ever since you made it.

I have been and still am, simply pointing out that the ADO.NET classes
(or any class) may require (or not) a string to be passed in a certain
way, but that has nothing to do with how VB.NET works with strings and
since this whole branch of the thread started with "it's not case
sensitive (VB.NET)", it makes no sense to me why you keep coming back
with the same example that has nothing to do with this stattement.

You've also made references to ASP.NET not being case-sensitive, but that
statement make no sense in any conversation since ASP.NET is an
architecture, not an object, nor a language. I think you mean to say
that in ASP.NET, there are certain types that you don't use in a WinForms
application, such as the System.Web.UI.WebControls.DataGrid and the
System.Windows.Forms.DataGrid and since these are two different types,
they handle case sensitivity differently. This again, boils down to the
type differences, not ASP.NET.

It's really very simple VB.NET is not a type, it's a language. VB.NET
has its rules about how strings are handled and any given type can have
its own rules that may differ, but to say that VB.NET strings are not
case-sensitve *sometimes* and then to show an example of a string being
used on a type, is an incorrect statement to make.

You've shown code that uses strings on types, but you haven't addressed
strings used by the language. I originally showed this code in my first
example:

Dim A As String = "Scott"
Bim B As String = "scott"

If A = B Then
MessageBox(A & "= " & B)
Else
MessageBox(A & " <" & B)
End If

You will find that the code in the Else always runs.

Your response was:

"Your message should be true, however, it is not always,"

but, that is incorrect to say, the else portion will always run. You
then went on to say:

"it is strange enough
that in AspNet the string literals from ADONET can be mixed uper and
lower
case. (I thought I had seen this in version 1.1)."

Which has nothing to do with VB.NET, it has to do with types.

You've made your point very clearly, you've just been labelling it
incorrectly and that's all I've been trying to point out to you.

Right comments, wrong conversation.


"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:en**************@TK2MSFTNGP02.phx.gbl...
>>Scott,

I told not to write anymore, however maybe does this helps in this
communication.

Maybe we are talking about different things, have a look at this tested
code and than to the word Dataset inside the session.

That it has different cases is my point, this is the same for Net.Data
names here while it is AFAIK impossible for WindowsForms to use then
different cases.

\\\\
'To test does this need a DataGrid on the page
Partial Class _Default
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim ds As System.Data.DataSet
DataGrid1.AllowPaging = True
DataGrid1.PagerStyle.Mode = PagerMode.NumericPages
DataGrid1.PageSize = 5
DataGrid1.PagerStyle.PageButtonCount = 5
If IsPostBack Then
ds = DirectCast(Session("Dataset"), System.Data.DataSet)
DataGrid1.DataSource = ds
Else
ds = New System.Data.DataSet
Dim dt As New System.Data.DataTable
dt.Columns.Add("Mycolumn")
For i As Integer = 0 To 100
dt.LoadDataRow(New Object() {i.ToString}, True)
Next
ds.Tables.Add(dt)
Session("dataSet") = ds
DataGrid1.DataSource = ds
DataBind()
End If
End Sub

Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal
e _
As System.Web.UI.WebControls.DataGridPageChangedEvent Args) _
Handles DataGrid1.PageIndexChanged
DataGrid1.CurrentPageIndex = e.NewPageIndex
DataGrid1.DataBind()
End Sub

End Class
///


"Scott M." <s-***@nospam.nospamschreef in bericht
news:%2******************@TK2MSFTNGP06.phx.gbl.. .
But, there aren't exceptions and that is my point. The language never
changes the way it handles strings, objects may, but the language
doesn't. To not separate the two things is right up there with those
who believe the Framework is the language and vice versa.


"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:uu**************@TK2MSFTNGP05.phx.gbl...
>I think the way as you are telling it can be more misleading.
>
Telling that something has always the same behaviour, while there are
exceptions, can lead that somebody can search for a problem weeks. To
prevent that was the only meaning of my message.
>
You can answer this message but I don't answer that anymore. Not to be
rude, however because there is enough written and we both will not add
new things anymore
>
Cor
>




Mar 11 '07 #35

P: n/a
Yes, as mentioned earlier, but I am referring to the default way that VB.NET
operates. The fundamental comparison of how a type deals with a string vs.
how the language deals with a string is what is at issue (at least for me)
here.

"Herfried K. Wagner [MVP]" <hi***************@gmx.atwrote in message
news:Ov**************@TK2MSFTNGP04.phx.gbl...
Scott,

"Scott M." <s-***@nospam.nospamschrieb:
>You've shown code that uses strings on types, but you haven't addressed
strings used by the language. I originally showed this code in my first
example:

Dim A As String = "Scott"
Bim B As String = "scott"

If A = B Then
MessageBox(A & "= " & B)
Else
MessageBox(A & " <" & B)
End If

You will find that the code in the Else always runs.

Again, only with 'Option Compare Binary' (the default) set, but not when
'Option Compare Text' is used.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Mar 11 '07 #36

This discussion thread is closed

Replies have been disabled for this discussion.