使用x-editable ASP.NET保存数据

时间:2013-11-08 12:50:26

标签: jquery asp.net handler x-editable

我正在使用x-editable控件。 我的代码是:

<a href="#" id="status" runat="server" clientidmode="Static" 
data-url="/Handler/Save.ashx" data-type="select" data-pk="1" 
data-title="Status">Yes</a>

我的javascript代码:

<script type="text/javascript">
    $(document).ready(function () {
        $.fn.editable.defaults.mode = 'popup';

        $('#status').editable({
            type: 'select',
            placement: 'right',
            value: 1,
            source:
            [
                { value: 1, text: 'Yes' },
                { value: 0, text: 'No' }
            ]
        });

    });
</script>

如何使用data-pk值和新值发送数据/Handler/Save.ashx以及如何设置处理程序?

感谢。

1 个答案:

答案 0 :(得分:0)

是啊,是的。

首先,我建议您使用WebMethod[()]代替ashx处理程序。 WebMethod更加用户友好;)。

[WebMethod()]
        public static string Save(string pk, string value)
        {
            string response = "";//TODO
            return response;
        }

在html中:

<a href="#" data-type="select" class="editable"
            data-pk="1" data-source="{value: 1, text: 'Yes' },{ value: 0, text: 'No' }"
            data-value="1" data-url="/SomePage.aspx/Save" data-title="Select options"
            />

你的javascript:

<script type="text/javascript">
$(document).ready(function(){
    $('.editable' ).on('save', function (e, params){
        var x = params.response;
        //$('.bottom-right').notify({message: {text: x}}).show();
    });
});
</script>
相关问题