1

i have a javascript array and want to access it when the page is posted on the server. Is this possible? I should be able to access the array using asp.net code. Thank you very much and have a nice day!

2 Answers 2

2

You can use HiddenField(runat=server) and store it there with comma separated value. and then access your hidden field in code behind.

to store in hidden field:

document.yourformname.Hidden1.value = test.join();

<input id="Hidden1" type="hidden" runat="server" />

Code Behind:

test = document.yourformname.Hidden1.value.split(",");
Sign up to request clarification or add additional context in comments.

1 Comment

You can try saving it in JSON and use Json.net (or other libs) to deserialize it.
1

to store in hidden field:

 document.getElementById("gGlobalArrayHidden").value = gGlobalArray.join(',');

<input id="Hidden1" type="hidden" runat="server" />

Code Behind:

string[] arr = gGlobalArrayHidden.Value.Split(",".ToCharArray());

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.