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

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

syedshaffee
P: 91
hey people ,

i need help
Expand|Select|Wrap|Line Numbers
  1.  $(document).ready(function () {    
  2.     //assigning alternative row style
  3. $("#Table_Data tr:even").addClass("evenrow");
  4. $("#Table_Data tr:odd").addClass("oddrow");
  5.  
  6.  $("#Table_Data tr").click(function(){
  7.    $(this).find(':checkbox').attr('checked', ! $(this).find(':checkbox').attr('checked'));    
  8.    if($(this).find(':checkbox').attr('checked'))
  9.         {
  10.               var html = '';
  11. $(' #Table_Data td').click(function() {
  12.     html = $(this).text();
  13.     alert(html);
  14. });
  15.  
  16.         }
  17.         else
  18.         {
  19.             $(this).removeClass('highlight');
  20.               $(this).addClass('evenrow');
  21.         }
  22. });
  23. });
  24.  
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???
Jan 19 '12 #1
Share this Question
Share on Google+
7 Replies


100+
P: 144
Try this.

Expand|Select|Wrap|Line Numbers
  1. dataToSave = "Save this String to Session"
  2. Session("saveData")= dataToSave
  3. Response.Write Session("saveData")
  4.  
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.
Jan 19 '12 #2

syedshaffee
P: 91
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
Jan 19 '12 #3

100+
P: 144
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'.

Expand|Select|Wrap|Line Numbers
  1. Session('saveData')= dataToSave; 
  2.  
I'm not sure of your question here though because you said you already know the syntax?
Jan 19 '12 #4

syedshaffee
P: 91
OK i will try this Thank u
Jan 19 '12 #5

syedshaffee
P: 91
hey i tried that but it doesn't work.It's giving a message 'Error on this page'
Jan 19 '12 #6

100+
P: 144
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.
Jan 19 '12 #7

100+
P: 144
Found this, but I haven't tried it.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Page_Render(ByVal sender As System.Object, ByVal e As
  2. System.EventArgs) Handles MyBase.PreRender
  3. RegisterClientScriptBlock("ddd", "<script type='text/javascript'> var
  4. color = '" + Session("Color") + "';</script>")
  5. End Sub
  6.  
  7.  
Jan 19 '12 #8

Post your reply

Sign in to post your reply or Sign up for a free account.