what are benefits of using a hidden field in ASP.NET when we can use another invisible element such as label or text box?
The hidden field generate element on the page, which cannot be seen but the client can get the element, set the data and pass to the server:
document.getElementById('<%= SomeHiddenField.ClientID %>').value = "data_pass_to_server";
after postback you can get the value:
var clientData = SomeHiddenField.Value; // "data_pass_to_server"
If you're using invisible textbox (
), there's no element generated in the html file.