how to save a value of the data in to a session

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • syedshaffee
    New Member
    • Jan 2012
    • 91

    how to save a value of the data in to a session

    hey people ,

    i need help
    Code:
     $(document).ready(function () {    
        //assigning alternative row style
    $("#Table_Data tr:even").addClass("evenrow");
    $("#Table_Data tr:odd").addClass("oddrow");
        
     $("#Table_Data tr").click(function(){
       $(this).find(':checkbox').attr('checked', ! $(this).find(':checkbox').attr('checked'));    
       if($(this).find(':checkbox').attr('checked'))
            {
                  var html = '';
    $(' #Table_Data td').click(function() {
        html = $(this).text();
        alert(html);
    });
    
            }
            else
            {
                $(this).removeClass('highlight');
                  $(this).addClass('evenrow');
            }
    });
    });
    This is the code which retrieves the value from a table-data when clicked on it now i want to store that data in a session How would i do that???
  • C CSR
    New Member
    • Jan 2012
    • 144

    #2
    Try this.

    Code:
    dataToSave = "Save this String to Session"
    Session("saveData")= dataToSave
    Response.Write Session("saveData")
    The "Session" object has some other features that you should probably study in addition to this, like how it can be used in the global.asa, and commands to use inside the page, etc. Hope this helps.

    Comment

    • syedshaffee
      New Member
      • Jan 2012
      • 91

      #3
      OK than x for the reply friend how do i do that in javascript/Dhtml i knew about he syntax of it than x a million for the reply


      can you? please help me on this

      Comment

      • C CSR
        New Member
        • Jan 2012
        • 144

        #4
        I misunderstood since your question was in category ASP.

        I think the syntax is basically the same. Maybe use single quotes?
        for the variable string 'saveData'.

        Code:
        Session('saveData')= dataToSave;
        I'm not sure of your question here though because you said you already know the syntax?

        Comment

        • syedshaffee
          New Member
          • Jan 2012
          • 91

          #5
          OK i will try this Thank u

          Comment

          • syedshaffee
            New Member
            • Jan 2012
            • 91

            #6
            hey i tried that but it doesn't work.It's giving a message 'Error on this page'

            Comment

            • C CSR
              New Member
              • Jan 2012
              • 144

              #7
              I checked a few things out. Apparently you can do it but not the way we're trying to because its stored server-side; Javascript is client side. I can try to look further into this or repost a question with a title like:

              "using javascript session variable"


              I just don't know that off the top of my head. Someone else should see this post and maybe help you. My apologies.

              Comment

              • C CSR
                New Member
                • Jan 2012
                • 144

                #8
                Found this, but I haven't tried it.

                Code:
                Private Sub Page_Render(ByVal sender As System.Object, ByVal e As
                System.EventArgs) Handles MyBase.PreRender
                RegisterClientScriptBlock("ddd", "<script type='text/javascript'> var
                color = '" + Session("Color") + "';</script>")
                End Sub

                Comment

                Working...