Pass data from Javascript to codebehind

2019-09-11 12:43发布

All -- I have been trying to find a working example of passing data from a Dojo function to an ASP.Net code behind. THe only post I found that at least offers an easy example is this POST

1条回答
Viruses.
2楼-- · 2019-09-11 13:04

Hidden inputs are how I do it for simple pages.

ASP.Net Markup (simplified):

function saveMyData() {
    var myData = resultOfSomeOtherFunction();
    var hiddenInput = document.getElementById('<%=HiddenField1.ClientID %>');
    hiddenInput.value = myData;
}
<asp:HiddenField ID="HiddenField1" runat="server" />

Code-Behind:

value = HiddenField1.Value;

When I want to get fancy, I'll post it to an API I write via an AJAX call.

查看更多
登录 后发表回答