Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To get a client variable "into c#", you need to make it part of a request to the server where c# is running. This can be as simple as appending it to a URL, or you may create a new field, or you may populate an existing field and send it.</p> <pre><code>// a variable var test = "a value to be sent to the server"; // put the value into a hidden field document.getElementById("hdnValue").value = test; // submit the form containing the hidden field document.getElementById("form1").submit(); </code></pre> <p>Since we are talking about c#, I assume the server is ASP.Net, either web forms or MVC. For MVC, ensure that there is a controller method that takes a corresponding parameter. For web forms, you may include <code>&lt;input type="hidden" runat="server" clientidmode="static" id="hdnValue" /&gt;</code>. The page will then have access to this value in the code behind.</p> <blockquote> <p>i want to travel a single specific value into my c# code ... i don't want everything</p> </blockquote> <p>An alternate (and possibly more elegant) way of sending a single value to the server is to POST the value asynchronously using AJAX. I would suggest using <a href="http://api.jquery.com/jQuery.ajax/" rel="nofollow">jQuery</a> to make this easier, but it can also be done in plain JavaScript.</p> <p>Here's a jQuery example of an AJAX post:</p> <pre><code>$.ajax({ url: "http://yourserverurl/", type: "POST", data: { test: "a value to be sent to the server" }, success: function(data){ // an optional javascript function to call when the operation completes successfully } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload