Pass data from Javascript to codebehind

筅森魡賤 提交于 2019-12-12 00:52:05

问题


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:


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.



来源:https://stackoverflow.com/questions/9576899/pass-data-from-javascript-to-codebehind

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!