|
-
Oct 19th, 2005, 05:44 AM
#1
Thread Starter
Hyperactive Member
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
-
Oct 19th, 2005, 06:18 AM
#2
Addicted Member
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.
-
Oct 19th, 2005, 06:57 AM
#3
Thread Starter
Hyperactive Member
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.
-
Oct 19th, 2005, 08:07 AM
#4
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
-
Oct 19th, 2005, 11:37 PM
#5
Thread Starter
Hyperactive Member
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
-
Oct 20th, 2005, 12:46 PM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|