0

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?

1
  • Can you show us your ASP code? Would help ... Commented Sep 29, 2011 at 12:05

4 Answers 4

1

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]
Sign up to request clarification or add additional context in comments.

Comments

1

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")
...

1 Comment

but my form is not submitting.
0

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.

2 Comments

ok thanks. Then in asp I have written this: strtextbox1 = request.Cookies("lineside1") Its working but I am storing textboxvalue in javascript cookie: var strline1side1 = document.frmartwork.side1textbox1.value; document.cookie="lineside1="+strline1side1+";path=/;"; When Reload th page I assign asp variable to textbox: ><input type="text" value="<%=strtextbox1%>" id="side1textbox1"> If I enter "this is test" then after reloading the page its showing me "thisistest" space between words is going. Why this is happening?Please help
That's what has been asked in Space between words is removing.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.