0

i claim my variable with javascript

<script type="text/javascript">{
            function choose(x) 
                this.x=x;

            }
            var x= document.getElementById("Select1").selectedIndex;

i want to use this x variable in my C# code

<%SqlParameter param = new SqlParameter("@ID", SqlDbType.Int);
param.Value =(i want to write x right here) how???????????%>
0

1 Answer 1

3

The only way to communicate between the client (JavaScript) and the server (C#) is to do a form submit or to use an Ajax call. So let's assume you'll want to send the value of the JavaScript variable to the server when the user submits. In that case you'll have to store the value of that variable inside a Hidden Field

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

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.