json调用后,asp按钮无法正常工作 [英] asp button is not working after a json call

查看:117
本文介绍了json调用后,asp按钮无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在asp.net中使用webmethod,通过它返回一些数组,循环中数组数据通过jquery附加在dropdownlist中。

如果dropdownlist为空(表示没有返回数据)通过查询web方法),我的保存按钮点击事件正在运行,但是当有一些数据返回并绑定到dropdownlisat时,按钮点击不起作用。



为什么会出现这种奇怪的行为?

I am using a webmethod in asp.net by which some array is returned and by a loop the array data is appended in dropdownlist by jquery.
If the dropdownlist is empty(means no data returned by query of web method),my save button click event is working,but when there is some data returned and bound to the dropdownlisat,button click is not working.

Why this strange behavious is occuring?

function loadCi() {
    var catid = $("#drpiccategory").val();
    var envid = $("#drpicenvironment").val();

    $.ajax({
        type: "POST",
        url: "incidentnewform.aspx/loadCIFiltered",
        data: JSON.stringify({ catid: catid, envid: envid }),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (data) {
            var rest = $('#drpAffectedCI');
            rest.empty();
            var listitems = "";
            $.each(data.d, function (index, item) {

                rest.append("<option value='" + item.split('~')[0] + "'>" + item.split('~')[1] + "</option>");
            });
            //alert(listitems);
            //rest.append("<option>test</option>");
        },
        failure: function (response) {
            alert("Some error occurred...");
        }
    });







我的按钮位于更新面板中,显示无法看到问题。现在我已将按钮保留在updatepanel外部并在回发后,此错误显示---------------------





无效的回发或回调参数。使用< pages enableeventvalidation =true>启用事件验证在配置或<%@ Page EnableEventValidation =true%>在一个页面中。出于安全考虑,此功能可验证回发或回调事件的参数是否来自最初呈现它们的服务器控件。如果数据有效且符合预期,请使用ClientScriptManager.RegisterForEventValidation方法注册回发或回调数据以进行验证。



每个人都说客户端更新了asp中不允许使用dropdown列表。它显示错误。

但是在这种情况下,如果这是真的,那么为什么开发json和jquery?我是通过webmethod和json从数据库中获取数据的并通过jquey循环将它们添加到dropdownlist中,以便我的进程变快。数据在下拉列表中显示正确。但按钮单击创建问题。




My button was in update panel,show cann't see the problem.Now I have kept the button outside updatepanel and after postback,this eror shows---------------------


Invalid postback or callback argument. Event validation is enabled using <pages enableeventvalidation="true"> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

Everyone saying that client side update of a dropdownlist is not allowed in asp.So it is showing error.
But in that case,if this is true,then why json and jquery is developed?I'm fetching data from database by webmethod and json and adding them in dropdownlist by jquey loop so that my process becomes fast.The data is shown correct in the dropdownlist. But button click creating problem.

推荐答案

# drpiccategory)VAL();
var envid =
("#drpiccategory").val(); var envid =


#drpicenvironment)。val();
("#drpicenvironment").val();


.ajax({
type: POST
url: incidentnewform.aspx / loadCIFiltered
data: JSON .stringify({catid:catid,envid:envid}) ,
contentType: application / json; charset = utf-8
dataType: json
成功: function (data){
var rest =
.ajax({ type: "POST", url: "incidentnewform.aspx/loadCIFiltered", data: JSON.stringify({ catid: catid, envid: envid }), contentType: "application/json; charset=utf-8", dataType: "json", success: function (data) { var rest =


这篇关于json调用后,asp按钮无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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