从jQuery检索值到C#代码 [英] Retrieve values from jQuery to C# Code

查看:60
本文介绍了从jQuery检索值到C#代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的jQuery脚本:

I have a jQuery script like this:

var sList = "";
$('input[type=checkbox]').each(function () {
var sThisVal = (this.checked ? "1" : "0");
sList += (sList=="" ? sThisVal : "," + sThisVal);
});
console.log (sList);

但是此脚本只是将sList值写入控制台. 如何在C#代码中检索sList值?并使用它.

But this script just writes sList values to console. How can I retrieve sList values in C# code? and use it.

推荐答案

添加隐藏字段:

<asp:HiddenField runat="server" ID="myList"/>

并编写JavaScript:

and write a JavaScript:

$("input[type=hidden][id$=myList]").val(sList);

,现在您应该将sList放在server events上,只需从C# code

and now you should get your sList on your server events, just see myList.Value from your C# code

这篇关于从jQuery检索值到C#代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆