Hi Guys
Please Help me i am getting this error whenever i am selecting any data from drodown lisy
[WebMethod]
public static List GetClassgrp()
{
string query = "select CODE,DESC_E from S_CLASS_GRP Order By 1";
string connectionstring = ConfigurationManager.ConnectionStrings["constrIND"].ConnectionString;
using (OracleConnection con = new OracleConnection(connectionstring))
{
using (OracleCommand cmd = new OracleCommand(query))
{
List classgrp = new List();
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
con.Open();
using (OracleDataReader sdr = cmd.ExecuteReader())
{
while (sdr.Read())
{
classgrp.Add(new ListItem
{
Value = sdr["CODE"].ToString(),
Text = sdr["DESC_E"].ToString()
});
}
}
con.Close();
return classgrp;
}
}
}
and this method i am calling by JQuery Ajax
$.ajax({
type: "POST",
url: "DropDwonPopulate.aspx/GetClassgrp",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) {
var ddlCLG = $("[id*=ddlCLG]");
ddlCLG.empty().append('');
$.each(r.d, function () {
ddlCLG.append($("").val(this['Value']).html(this['Text']));
});
}
});
and this is my error

Bikesh SrivastavaPosted Nov 17, 2016, 2:02 PM
Manas MohapatraPosted Nov 17, 2016, 1:39 PM
Because ASP.NET checks each controls after postback.
In order to avoid problem, you can change the page directive as follow
<%@ Page EnableEventValidation="false" %>
or in Web.Config
Be careful, it disables the server side validation of control.
Note: If you want to achieve the above you can use html drop down and use a
hidden field and get the selected value from hidden field rather than drop down it will work.