Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Step Right Up, Get Yer Session 'ere

Step Right Up, Get Yer Session 'ere

Scheduled Pinned Locked Moved The Weird and The Wonderful
asp-netcsharpjavascriptdatabasecom
8 Posts 7 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AspDotNetDev
    wrote on last edited by
    #1

    Public Sub SomeMethod()
    ' ...
    For Each da As DataRow In myTable.Rows
    da(11) = i + 1
    items(i) = da(0) & ":" & da(1) & ":NaN:" & da(3) & ":" & da(4) & ":" & da(5) &
    ":" & da(6) & ":" & da(7) & ":" & da(8) & ":" & da(9) & ":" & da(10) & ":" & da(11) & ":" & da(1)
    i += 1
    Next
    Session("itemTable") = items
    '...
    End Sub

    <AjaxMethod()> _
    Public Function GetSessionData(ByVal name As String) As Object
    Return HttpContext.Current.Session(name)
    End Function

    That is some code I just came across (I took out some stuff and renamed some things to protect the innocent). That basically gets information from a DataTable by index (rather than by field name), puts it into a colon-separated-value string (some of the data items include company names and addresses, which could potentially contain colons) that is stored in an array that gets shoved into the session. There is then some JavaScript that calls the server to get that session data (or any session data a client script feels like grabbing). Luckily, I am replacing this code entirely.

    [Managing Your JavaScript Library in ASP.NET]

    C L B M 4 Replies Last reply
    0
    • A AspDotNetDev

      Public Sub SomeMethod()
      ' ...
      For Each da As DataRow In myTable.Rows
      da(11) = i + 1
      items(i) = da(0) & ":" & da(1) & ":NaN:" & da(3) & ":" & da(4) & ":" & da(5) &
      ":" & da(6) & ":" & da(7) & ":" & da(8) & ":" & da(9) & ":" & da(10) & ":" & da(11) & ":" & da(1)
      i += 1
      Next
      Session("itemTable") = items
      '...
      End Sub

      <AjaxMethod()> _
      Public Function GetSessionData(ByVal name As String) As Object
      Return HttpContext.Current.Session(name)
      End Function

      That is some code I just came across (I took out some stuff and renamed some things to protect the innocent). That basically gets information from a DataTable by index (rather than by field name), puts it into a colon-separated-value string (some of the data items include company names and addresses, which could potentially contain colons) that is stored in an array that gets shoved into the session. There is then some JavaScript that calls the server to get that session data (or any session data a client script feels like grabbing). Luckily, I am replacing this code entirely.

      [Managing Your JavaScript Library in ASP.NET]

      C Offline
      C Offline
      Chris Meech
      wrote on last edited by
      #2

      Let me guess. The programmer thought CSV meant "Colon Separated Values". :-D Any reason for "da(1)" to be included twice.

      Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]

      J 1 Reply Last reply
      0
      • A AspDotNetDev

        Public Sub SomeMethod()
        ' ...
        For Each da As DataRow In myTable.Rows
        da(11) = i + 1
        items(i) = da(0) & ":" & da(1) & ":NaN:" & da(3) & ":" & da(4) & ":" & da(5) &
        ":" & da(6) & ":" & da(7) & ":" & da(8) & ":" & da(9) & ":" & da(10) & ":" & da(11) & ":" & da(1)
        i += 1
        Next
        Session("itemTable") = items
        '...
        End Sub

        <AjaxMethod()> _
        Public Function GetSessionData(ByVal name As String) As Object
        Return HttpContext.Current.Session(name)
        End Function

        That is some code I just came across (I took out some stuff and renamed some things to protect the innocent). That basically gets information from a DataTable by index (rather than by field name), puts it into a colon-separated-value string (some of the data items include company names and addresses, which could potentially contain colons) that is stored in an array that gets shoved into the session. There is then some JavaScript that calls the server to get that session data (or any session data a client script feels like grabbing). Luckily, I am replacing this code entirely.

        [Managing Your JavaScript Library in ASP.NET]

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        AspDotNetDev wrote:

        I am replacing this code entirely

        Changing or replacing it is easy, but will it be an improvement? :laugh:

        Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

        Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

        A 1 Reply Last reply
        0
        • L Luc Pattyn

          AspDotNetDev wrote:

          I am replacing this code entirely

          Changing or replacing it is easy, but will it be an improvement? :laugh:

          Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

          Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

          A Offline
          A Offline
          AspDotNetDev
          wrote on last edited by
          #4

          Well it doesn't get any worse than the code already is, so there's really only one direction to go. Rapture, here I come!

          [Managing Your JavaScript Library in ASP.NET]

          1 Reply Last reply
          0
          • A AspDotNetDev

            Public Sub SomeMethod()
            ' ...
            For Each da As DataRow In myTable.Rows
            da(11) = i + 1
            items(i) = da(0) & ":" & da(1) & ":NaN:" & da(3) & ":" & da(4) & ":" & da(5) &
            ":" & da(6) & ":" & da(7) & ":" & da(8) & ":" & da(9) & ":" & da(10) & ":" & da(11) & ":" & da(1)
            i += 1
            Next
            Session("itemTable") = items
            '...
            End Sub

            <AjaxMethod()> _
            Public Function GetSessionData(ByVal name As String) As Object
            Return HttpContext.Current.Session(name)
            End Function

            That is some code I just came across (I took out some stuff and renamed some things to protect the innocent). That basically gets information from a DataTable by index (rather than by field name), puts it into a colon-separated-value string (some of the data items include company names and addresses, which could potentially contain colons) that is stored in an array that gets shoved into the session. There is then some JavaScript that calls the server to get that session data (or any session data a client script feels like grabbing). Luckily, I am replacing this code entirely.

            [Managing Your JavaScript Library in ASP.NET]

            B Offline
            B Offline
            BillW33
            wrote on last edited by
            #5

            Yeah, that looks like code that should be replaced. Sadly, I see far too much legacy code that should be replaced. :sigh:

            Just because the code works, it doesn't mean that it is good code.

            modified on Monday, May 23, 2011 9:18 AM

            R 1 Reply Last reply
            0
            • C Chris Meech

              Let me guess. The programmer thought CSV meant "Colon Separated Values". :-D Any reason for "da(1)" to be included twice.

              Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]

              J Offline
              J Offline
              Jeroen De Dauw
              wrote on last edited by
              #6

              CSV is actually a great example of how not to design a text-based data format. UNIX-style DSV is much more sane, and there colon is the default separator. So I wouldn't make fun of using colons to delimiter values, even though the rest of the code is horrible.

              Jeroen De Dauw
              Blog ; Wiki

              1 Reply Last reply
              0
              • A AspDotNetDev

                Public Sub SomeMethod()
                ' ...
                For Each da As DataRow In myTable.Rows
                da(11) = i + 1
                items(i) = da(0) & ":" & da(1) & ":NaN:" & da(3) & ":" & da(4) & ":" & da(5) &
                ":" & da(6) & ":" & da(7) & ":" & da(8) & ":" & da(9) & ":" & da(10) & ":" & da(11) & ":" & da(1)
                i += 1
                Next
                Session("itemTable") = items
                '...
                End Sub

                <AjaxMethod()> _
                Public Function GetSessionData(ByVal name As String) As Object
                Return HttpContext.Current.Session(name)
                End Function

                That is some code I just came across (I took out some stuff and renamed some things to protect the innocent). That basically gets information from a DataTable by index (rather than by field name), puts it into a colon-separated-value string (some of the data items include company names and addresses, which could potentially contain colons) that is stored in an array that gets shoved into the session. There is then some JavaScript that calls the server to get that session data (or any session data a client script feels like grabbing). Luckily, I am replacing this code entirely.

                [Managing Your JavaScript Library in ASP.NET]

                M Offline
                M Offline
                meaningoflights
                wrote on last edited by
                #7

                I cant overlook that it would have been so much easier to keep the datatable in the session rather than mangle it as a colon csv, there must have been a good reason... then again we see this stuff on DailyWTF.com all the time

                1 Reply Last reply
                0
                • B BillW33

                  Yeah, that looks like code that should be replaced. Sadly, I see far too much legacy code that should be replaced. :sigh:

                  Just because the code works, it doesn't mean that it is good code.

                  modified on Monday, May 23, 2011 9:18 AM

                  R Offline
                  R Offline
                  Rob Grainger
                  wrote on last edited by
                  #8

                  Isn't that the definition of legacy code?

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups