0

Hi guy i have a javasciprt will create a value , is that any way for me to capture the value in my c# back end code.

function GetKey(){ return Key; } //key is a combination value 

Thank you

0

2 Answers 2

3

C# in backend

public String MyVariable;

MyVariable = "Some Value";

ASPX

<%=MyVariable %>
Sign up to request clarification or add additional context in comments.

Comments

2
  1. via ajax
  2. You can put it into your aspx page code and pass it to your js (if you are using asp). If Key is an object, you can serialize it to json string and use JSON parser to deserialize it. If it is a basic type, use <%= Key %> in your asp page is OK. (Note you cannot put the code in your js file)
<script type="text/javascript"> 
var key = JSON.parse('<%=JsonConvert.SerializeObject(someObj.GetKey()) %>'); 
//now you can use key in your js logic 
</script>

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.