如何将复选框列表值传递给静态方法。 [英] How to pass checkbox list values to static method.

查看:91
本文介绍了如何将复选框列表值传递给静态方法。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我有复选框列表,每次单击复选框都会生成一个值。在这种情况下,我想将复选框值传递给webservice静态方法。



我尝试了什么:



我试过session.in这个我得到了值。但是我们没有点击任何复选框显示最后一个会话值。

Hi I have checkbox list ,every time we click a checkbox there is an value will be generated.In this case i want to pass checkbox value to webservice static method.

What I have tried:

I tried session.in this i got the value.But we did not click any checkbox the last session values is displayed.

推荐答案

您只需将复选框的状态作为参数传递给您的javascript中的webmethod。您必须记住,您的webmethod不是页面回发的一部分,因此它无法访问控件,它只能访问您作为方法参数发送的内容。因此,您的网络方法将类似于



You just have to pass the state of the checkbox as a parameter to your webmethod in your javascript. You have to remember that your webmethod is not part of a page postback so it can't access controls, it only has access to what you send in as a parameter to the method. So your webmethod will be something like

void UpdateCheckbox(bool value)
{
    // do something with value
}





并且你将传递一个名为value的参数,该参数是否检查你的checkox。



谷歌调用webmethod jquery作为你的例子从jquery调用webmethod,谷歌找出是否勾选复选框jquery找到你的复选框的状态,现在只需将两者放在一起。



and you'll pass the method a parameter called "value" that has whether your checkox is checked or not.

Google "call webmethod jquery" for examples of how you call a webmethod from jquery, and google "find out if checkbox is checked jquery" to find the state of your checkbox, now just put the two together.


这篇关于如何将复选框列表值传递给静态方法。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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