ASP.net Uploadify查询字符串值复选框 [英] ASP.net Uploadify Querystring checkbox value

查看:136
本文介绍了ASP.net Uploadify查询字符串值复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Uploadify与ASP.Net 4.0和通用处理器的后端。
现在我可以使用Uploadify的scriptData一部分。如果我只知道如何阅读正在被发布到通用处理器等等,而不是我选择了刚刚硬编码的查询字符串发送通过查询字符串,我已经测试所需的数据和它的作品的JSON但是当我试图让上,不管使用它只是传递价值的VAL()选项框的值,如果复选框或不作检查。我也试图简单地使用$('#mainimg')是(':检查')。这不给我任何东西。

I am using Uploadify with ASP.Net 4.0 and a Generic Handler for the backend. now I could use the scriptData part of Uploadify If I only knew how to read the JSon that is being posted to the Generic Handler so instead I opted for just sending the needed data through querystring which I have tested by hardcoding the query string and it works but when I try to get the value of a checkbox using the val() option it just passes the value of "on" no matter if the check box is or is not checked. I have also tried simply using $('#mainimg').is(':checked') which does not give me anything.

            $('#file_upload').uploadify({

            'uploader': '/uploadify/uploadify.swf',
            'script': '/services/Upload.ashx?ismain=' + $('#mainimg').val(), <--- HERE IS THE PROBLEM
            'multi': false,
            'fileExt': '*.jpg;*.gif;*.png',
            'sizeLimit': 10000000,
            'scriptAccess': 'sameDomain',
            'cancelImg': '/uploadify/cancel.png',
            'onAllComplete': function (event, data) {
                alert(data.filesUploaded + ' files uploaded successfully!');
            },
            'onCancel': function (event, ID, fileObj, data) {
                alert('The upload of ' + fileObj.name + ' has been canceled!');
            },
            'onError': function (event, ID, fileObj, errorObj) {
                alert(errorObj.type + ' Error: ' + errorObj.info);
            },
            'onSelectOnce': function (event, data) {
                alert(data.filesSelected + ' files were selected for upload.');
            },
            'auto': true

        });

我已经设置使用此复选框的值

I've set the value of the checkbox using this

$('#mainimg').click(function () {

                        if ($('#mainimg').is(':checked')) {
                            $('#mainimg').val('true');
                        }
                        else { $('#mainimg').val('false'); }
                        alert($('#mainimg').val());
                    });

我甚至尝试使用这种code设置变量

I have even tried setting a variable using this code

$('#mainimg').click(function () {

                        if ($('#mainimg').is(':checked')) {
                            checkboxStatus = false; ;
                        }
                        else { checkboxStatus = true; }
                        alert(checkboxStatus);
                    });

但是,即使我会与警报测试它,它显示了警报正确的数据时,它进入它只是提供了价值uploadify脚本假

But even though I would test it with an alert and it shows the right data in the alert when it goes to the uploadify script it just provides the value of 'false'

任何人都可以看到它是什么,我做错了什么?

can anyone see what it is that I am doing wrong here?

推荐答案

您是正确的,对于复选框的值始终为开,让你有,如果复选框被选中送别的东西,即该文复选框,或者其标签的价值。

You are right that the value for the checkbox is always "on", so you have to send something else if the checkbox is checked, i.e. the text of the checkbox, or its label's value.

(...)'script': '/services/Upload.ashx?ismain=' + $('#mainimg').is(':checked')?'true':'false',

这篇关于ASP.net Uploadify查询字符串值复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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