Reputation: 957
I have stored text box value in JavaScript variable
var strline1side1 = document.frmartwork.side1textbox1.value;
and then saved that value in JavaScript cookie
document.cookie="lineside1="+strline1side1+";path=/;";
now I want to save this cookie in asp variable.
I tried this:
<%=ASPVariable%> = document.frmartwork.side1textbox1.value;
but its not working
How can I do this?
Upvotes: 0
Views: 2354
Reputation: 6903
You could store the value in a formfield e.g. hidden field and then access its contents by checking the Request.Forms collection
...
myCookieValue = Request.Forms("side1textbox1")
...
Upvotes: 1
Reputation: 189457
Fascinating array of answers here is my 2 pennies worth
<%
Dim aspVar
aspVar = Request.Cookies("lineside1");
%>
Of course you understand this code will not see the cookie until the page in which is resides is requested after the client side code has set the cookie.
Upvotes: 0
Reputation: 2597
you can use Set-Cookie Header rather than javascript
The Set-Cookie response header uses the following format:
Set-Cookie: <name>=<value>[; <name>=<value>]...
[; expires=<date>][; domain=<domain_name>]
[; path=<some_path>][; secure][; httponly]
Upvotes: 1
Reputation: 318508
ASP runs on the server, JavaScript on the client. So you obviously cannot write to ASP variables from JavaScript.
You need to perform an AJAX call if you want to change something on the server.
Upvotes: 0