Results 1 to 6 of 6

Thread: Client value to server ** Resolved **

  1. #1

    Thread Starter
    Hyperactive Member vbud's Avatar
    Join Date
    Jan 2002
    Location
    Mru 20 17S, 57 33E Goal: Get out of the BOX Status: In The Shadows!!! Target Posts: 3,000,000,000
    Posts
    378

    Client value to server ** Resolved **

    I dont know if this at all possible, but i need to retrieve values from client side to server side. I've been trying to use javascript but with no hope till now. my problem is that i have a datagrid and when the user clicks on a given row i retrieve the value of the primary key for the current row and store it on client side using javascript. now on a postback i need to retrieve this value and use it in my code behind. how do i achieve that? anyone please?

    I have been trying to use document.cookie to store the value but dont know how to retrieve in on server side. it also seems that javascript cannot store values in session variables, or am i wrong here?

    thanx.
    Last edited by vbud; Oct 19th, 2005 at 11:38 PM. Reason: Resolved
    >!v!<
    Free your mind, stop thinking
    http://inspirone.blogspot.com

    Please rate this post if it helped you

  2. #2
    Addicted Member
    Join Date
    Aug 2004
    Location
    Cape Town, South Africa
    Posts
    149

    Re: Client value to server

    I assume you are using ASP.NET? That is essentially the point of asp.net, to allow for easy passing of values between client side and server side...

    I dont quite understand your problem, do you want to postback when the user clicks on a row of the datagrid? If so (assuming your datagrid is an asp:datagrid) you can retrieve the value in the onItemCommand event of your datagrid on the server using the datakeys property of the grid.

  3. #3

    Thread Starter
    Hyperactive Member vbud's Avatar
    Join Date
    Jan 2002
    Location
    Mru 20 17S, 57 33E Goal: Get out of the BOX Status: In The Shadows!!! Target Posts: 3,000,000,000
    Posts
    378

    Re: Client value to server

    yes its is through ASP.net. I know for the itemCommand but my purpose is not to cause any postback when clicking on the datagrid. so that is the reason i retrieve the value in javascript. so on selection there is no postback, only when the user clicks on a button that a postback is triggered and operations need to be performed on the selectd value.
    >!v!<
    Free your mind, stop thinking
    http://inspirone.blogspot.com

    Please rate this post if it helped you

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Client value to server

    Yes, but when the user clicks, you can determine the selected value from the datagrid, can't you?

    OTOH, to do exactly what you want, start by creating a hidden field (<input type="hidden"...) on the page with runat=server in it. Make your javascript function update the value in this hidden field, and when a postback occurs, you can look at the value in the hidden field.

    HTH

  5. #5

    Thread Starter
    Hyperactive Member vbud's Avatar
    Join Date
    Jan 2002
    Location
    Mru 20 17S, 57 33E Goal: Get out of the BOX Status: In The Shadows!!! Target Posts: 3,000,000,000
    Posts
    378

    Re: Client value to server

    Ok thanx mendhak, I think i got it. I have used the same principle of hidden field in other situations and i think this would best suit this one also. thanx again
    >!v!<
    Free your mind, stop thinking
    http://inspirone.blogspot.com

    Please rate this post if it helped you

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Client value to server ** Resolved **

    JFYI, for next time, when you wanted to add resolved, you could have chosen the Resolved menu item from the Thread Tools menu at the top of this page.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width