Class functions not showing

Discussion in 'ASP .Net' started by David C, Oct 2, 2009.

  1. David C

    David C Guest

    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
     
    David C, Oct 2, 2009
    #1
    1. Advertising

  2. "David C" <> wrote in
    news:O$:

    > 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! |
    *******************************************
     
    Gregory A. Beamer, Oct 2, 2009
    #2
    1. Advertising

  3. David C

    David C Guest

    "Mark Rae [MVP]" <> wrote in message
    news:%...
    > "David C" <> wrote in message
    > news:O$...
    >
    >> What am I missing?

    >
    > Sounds like you've forgotten to declare the function as static...
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net


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

    David
     
    David C, Oct 2, 2009
    #3
  4. David C

    David C Guest

    "Gregory A. Beamer" <> wrote in message
    news:Xns9C989AFC57FE4gbworld@207.46.248.16...
    > "David C" <> wrote in
    > news:O$:
    >
    >> 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! |
    > *******************************************


    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
     
    David C, Oct 2, 2009
    #4
  5. David C

    David C Guest

    "Mark Rae [MVP]" <> wrote in message
    news:...
    > "David C" <> wrote in message
    > news:...
    >
    >> Below is the Class so let me know what is wrong.

    >
    > 1) It's written in VB.NET... ;-) (ducks for cover)
    >
    > 2) Public Shared Function ValidPIN(....
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net


    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
     
    David C, Oct 2, 2009
    #5
  6. "Mark Rae [MVP]" <> wrote in news:uRb6W35QKHA.220
    @TK2MSFTNGP02.phx.gbl:

    > 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! |
    *******************************************
     
    Gregory A. Beamer, Oct 5, 2009
    #6
  7. "David C" <> wrote in
    news::

    > 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! |
    *******************************************
     
    Gregory A. Beamer, Oct 5, 2009
    #7
  8. "Mark Rae [MVP]" <> wrote in news:eT$tG3cRKHA.1232
    @TK2MSFTNGP05.phx.gbl:

    >> Like Microsoft.VisualBasic.Compatibility? <g>

    >
    > Ugh! Don't get me started...
    >


    Too late. :p

    Peace and Grace,

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

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

    *******************************************
    | Think outside the box! |
    *******************************************
     
    Gregory A. Beamer, Oct 5, 2009
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ray Booysen
    Replies:
    2
    Views:
    654
    Ray Booysen
    Mar 28, 2006
  2. E11
    Replies:
    1
    Views:
    4,842
    Thomas Weidenfeller
    Oct 12, 2005
  3. Timothy Wong
    Replies:
    3
    Views:
    425
    Timothy Wong
    May 20, 2004
  4. Xiangliang Meng
    Replies:
    1
    Views:
    1,629
    Victor Bazarov
    Jun 21, 2004
  5. christopher diggins
    Replies:
    16
    Views:
    769
    Pete Becker
    May 4, 2005
Loading...

Share This Page