0

ASP.NET, C#, Javascript

I have an unknown number of results returning from a SQL query.

I then make changes to their values with javascript and set a value on a hidden input (generated programmatically on page_init).

My question is: what's the best way to access the hidden input variables values in the C# code behind file.

2 Answers 2

4

Use the Request.Form property, like this:

var value = Request.Form["MyHiddenInputName"];

If you don't know how many items there are, you can loop through its Keys property.

Sign up to request clarification or add additional context in comments.

Comments

0

You will be able to examine the Request collection during a post back to get the value directly like traditional ASP if all else fails.

If you are adding the control server side, which it sounds like you are, you'll actually be able to use the instance of the control you create in Init to get its value (after Init completes).

Comments

Your Answer

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