使用jQuery使用级联下拉列表时的回发问题 [英] Problem in Postback when using cascading dropdowns using jquery
问题描述
你好朋友,
在使用母版页的网页中,我有以下下拉菜单
Hello friends,
In my web page which uses master page, I have following dropdowns
1. ddlGEO<br />
2. ddlVC
在页面加载中,我正在填充ddlGEO.
我通过以下代码使用JQuery填充ddlVC
In page load I''m filling the ddlGEO.
I''m populating ddlVC using JQuery through following code
<script>
$(document).ready(function () {
});
function fillVC() {
try {
var objGEO = document.getElementById(''<%= ddlGeo.ClientID %>''); //$("#hdnEmpNo").val();
var objGEOValue = objGEO.value;
var objHdn = document.getElementById(''<%= hdnEmpNo.ClientID %>''); //$("#hdnEmpNo").val();
var objHdnValue = objHdn.value;
$.ajax({
type: "POST",
url: "FWB_DUOverhead.aspx/strgetVC",
data: "{strGEO: ''" + objGEOValue + "'', intEmpNo: ''" + objHdnValue + "''}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function Success(response) {
var result = response.d;
var objVC = result.split(";");
var VClength = objVC.length;
//document.getElementById(''imgLoader'').style.display = "block";
if (VClength > 0) {
try {
var ddlVC = document.getElementById(''<%= ddlVC.ClientID %>'');
var option = document.createElement("option");
ddlVC.options.length = 0;
option.value = 0;
option.text = "- Select -";
ddlVC.options.add(option);
for (var i = 0; i < VClength - 1; i++) {
var objVCDetails = objVC[i].split(''|'');
var VCDetailsLength = objVCDetails.length;
var option = document.createElement("option");
option.value = objVCDetails[0];
option.text = objVCDetails[1];
ddlVC.options.add(option);
}
//document.getElementById(''imgLoader'').style.display = "none";
}
catch (e) { alert(e); }
}
},
error: function (data, status, jqXHR) {
alert(''There was an error.'');
}
});
}
catch (e) {
alert(e);
}
}
</script>
我通过以下方式调用此javascript函数:
I call this javascript function in following way:
<asp:DropDownList ID="ddlGeo" runat="server" Width="100px"
onChange="fillVC();">
</asp:DropDownList>
问题:
On ddlVC selected index change I''m filling the grid
错误:
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.
尝试过的解决方案:
<%@ Page EnableEventValidation="false" %>
结果:
Postback does not happen, grid does not getting filled and the ddlVC gets clear
知道如何克服这个问题吗?
在此先感谢
Problem:
On ddlVC selected index change I''m filling the grid
Error:
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.
Solution Tried:
<%@ Page EnableEventValidation="false" %>
Result:
Postback does not happen, grid does not getting filled and the ddlVC gets clear
Any idea how to overcome this problem?
Thanks in advance
推荐答案
(document).ready(function(){ }); 函数fillVC(){ 尝试 { var objGEO = document.getElementById(''<%= ddlGeo.ClientID%>'')); //
(document).ready(function () { }); function fillVC() { try { var objGEO = document.getElementById(''<%= ddlGeo.ClientID %>''); //
(#hdnEmpNo").val(); var objGEOValue = objGEO.value; var objHdn = document.getElementById(''<%= hdnEmpNo.ClientID%>'')); //
("#hdnEmpNo").val(); var objGEOValue = objGEO.value; var objHdn = document.getElementById(''<%= hdnEmpNo.ClientID %>''); //
(#hdnEmpNo").val(); var objHdnValue = objHdn.value;
("#hdnEmpNo").val(); var objHdnValue = objHdn.value;
这篇关于使用jQuery使用级联下拉列表时的回发问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!