title: Passing JQuery variable to code behind in asp.net
body: <p>I have been trying for a while to get the variable passed from the JQuery function to the code behind so that I can enter it into a database via an SQL statement.  However, I never seem to get the variable passed.  Or if it is passing, I can't seem to get it to display to make sure it has been passed.  Can anyone see what's wrong with my script?</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
    $(function () {
        var comment = $("#comment"),
        allFields = $([]).add(comment);
        $('#&lt;%= hidden.ClientID %&gt;').val(comment);
  
  
        $("#dialog-form").dialog({
            autoOpen: false,
            height: 300,
            width: 350,
            modal: true,
            buttons: {
                "Add Comment": function () {
                    var bValid = true;
                    allFields.removeClass("ui-state-error");
                    if (bValid) {
                        $("#comments tbody").append("&lt;tr&gt;" +
                          "&lt;td&gt;" + comment.val() + "&lt;/td&gt;" +
                          "&lt;td&gt;" + "&lt;%=currentUser%&gt;" + "&lt;/td&gt;" +
                          "&lt;/tr&gt;");
  
                        $(this).dialog("close");
                        //                          
                    }
                },
                Cancel: function () {
                    $(this).dialog("close");
                }
            },
            close: function () {
                allFields.val("").removeClass("ui-state-error");
            }
        });
  
        $("#NewComment")
      .button()
      .click(function () {
          $("#dialog-form").dialog("open");
  
      });
    });  
      &lt;/script&gt;  
  </code></pre>
  
  <p>And here is my hidden input field:</p>
  
  <pre><code>&lt;input id="hidden" type="hidden" runat="server" /&gt;
  </code></pre>