views:

65

answers:

1

I have a hidden asp.net MVC control in the form:

<%= Html.HiddenFor(m => m.NodeId) %>

my JavaScript / jQuery code:

var DeleteEntireItem = '<% = btnDeleteEntireMenu.ClientID%>';
var Node;
debugger;

$('#' + DeleteEntireItem).click(function () {
    Node = NodeValue;
    document.forms[0].submit();
});

How can I assign the value of variable 'Node' to the asp.net MVC hidden control?

+1  A: 

You can set the value attribute of a hidden input tag by selecting it using the property name and using the jquery val() method.

In your case this becomes:

$("#NodeId").val(Node)
Stefaan