Class functions not showing

  • Thread starter Thread starter David C
  • Start date Start date
D

David C

I created a new class in my App_Code folder and added a public function.
When I go to a code page on one of the web pages and I type in the
xxClass.Function I am not getting any intellisense that shows the function
name to pick from. Then if I spell out the whole name, e.g.
ValidateClass.GetPINno it tells me the function does not exist? What am I
missing? The same process works fine in another web application.
p.s. Using VS 2008 and .net 3.5

David
 
I created a new class in my App_Code folder and added a public
function. When I go to a code page on one of the web pages and I type
in the xxClass.Function I am not getting any intellisense that shows
the function name to pick from. Then if I spell out the whole name,
e.g. ValidateClass.GetPINno it tells me the function does not exist?
What am I missing? The same process works fine in another web
application. p.s. Using VS 2008 and .net 3.5

Does it look like this:

public class xxClass
{
public void Function()
{
}
}

Public Class xxClass

Public Function MyFunction() as Something
End Function

End Class

or this

public class xxClass
{
public static void MyFunction()
{
}
}

Public Class xxClass

Public Shared Function MyFunction() as Something
End Function

End Class

If the former, you cannot declare like xxClass.MyFunction, as the items
require an instance. You can do this, however:

xxClass cls = new xxClass();
cls.MyFunction();

Dim cls As New xxClass()
cls.MyFunction()

the other possibility is you are not getting to the class period, as it
is not recognizing the namespace.

As a rule, I DO NOT use App_Code for anything. In general, people stick
application code there, and ASP.NET is a user interface, not an
application. If I have UI specific code, I will still create a library
named something like CompanyName.ProjectName.UI.{LibraryTypeNameHere}.

Peace and Grace,

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
Mark Rae said:
Sounds like you've forgotten to declare the function as static...

Sorry Mark, I don't know what you mean. It looks exactly like others that
work fine.

David
 
Gregory A. Beamer said:
Does it look like this:

public class xxClass
{
public void Function()
{
}
}

Public Class xxClass

Public Function MyFunction() as Something
End Function

End Class

or this

public class xxClass
{
public static void MyFunction()
{
}
}

Public Class xxClass

Public Shared Function MyFunction() as Something
End Function

End Class

If the former, you cannot declare like xxClass.MyFunction, as the items
require an instance. You can do this, however:

xxClass cls = new xxClass();
cls.MyFunction();

Dim cls As New xxClass()
cls.MyFunction()

the other possibility is you are not getting to the class period, as it
is not recognizing the namespace.

As a rule, I DO NOT use App_Code for anything. In general, people stick
application code there, and ASP.NET is a user interface, not an
application. If I have UI specific code, I will still create a library
named something like CompanyName.ProjectName.UI.{LibraryTypeNameHere}.

Peace and Grace,

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************

Below is the Class so let me know what is wrong. Thanks.
David

Imports System.Data.SqlClient
Imports Microsoft.VisualBasic

Public Class GeneralClass
Public Function ValidPIN(ByVal intPIN As Integer, ByVal strEmployeeCode
As String) As Boolean
Dim bolValid As Boolean = False

Dim conData As SqlConnection = New
SqlConnection(ConfigurationManager.ConnectionStrings("MarsConnectionString").ConnectionString)
conData.Open()
Dim strSQL As String
'Get Stage targets and place in text boxes
strSQL = "SELECT TimePIN" & _
" FROM dbo.Employees" & _
" WHERE (EmployeeCode = '" & strEmployeeCode & "')"

Dim cmdSelect As SqlCommand = New SqlCommand(strSQL, conData)
Dim dtr As SqlDataReader = cmdSelect.ExecuteReader()
If dtr.HasRows Then
While dtr.Read()
If dtr("TimePIN") = intPIN Then
bolValid = True
End If
End While
End If
dtr.Close()
conData.Close()

End Function
End Class
 
Mark Rae said:
1) It's written in VB.NET... ;-) (ducks for cover)

2) Public Shared Function ValidPIN(....

Thank you. So is it better practice to write the code, compile to DLL and
put in Bin folder or just use DAL? Thanks.

David
 
Me neither. It's just another example of the "training wheels" in Visual
Studio.NET...

Like Microsoft.VisualBasic.Compatibility? <g>

Peace and Grace,

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
Thank you. So is it better practice to write the code, compile to DLL
and put in Bin folder or just use DAL? Thanks.

From my perspective, start with a separate libraries for models and your
business classes (the application). You then add a Data Access layer to
persist the model to a data store and a UI to get user interaction.

The UI layer, whether ASP.NET, windows forms or Fred (assuming someone
makes a UI named Fred some day), is a thin layer on top of the app code. If
you write it any other way, you are doing it wrong, imo.

The next step is making sure you don't tightly couple these layers, but
that is a story for another day.

Peace and Grace,

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
Back
Top