hi
I am using MVC 2.0 web application where there few buttons whose onclick i call a action method, but when i press search button for the first time , the action method is called but after that if i try to click the search button the action method is not getting called.
Also let me tell you that i am using the JQ Grid to display the data on button onclick. Please see below code snippet.
function LoadGrid(data, type) {
var showGrid = $("#showGrid");
var navigation = $("#navigation");
showGrid.jqGrid({
url: '/Customer/CustomerSearchInfo',
datatype: 'json',
mtype: 'POST',
cache: false,
postData: { param: data, type: type },
colNames: ['Customer Name', 'Contact Name', 'Company Number', 'Customer Number', 'Link Number', 'Phone', 'SalesRep Name', 'Sequence'],
colModel: [
{ name: 'COMPANY_NAME', index: '1', align: 'left', sortable: true },
{ name: 'CONTACT_NAME', index: '2', align: 'left', sortable: true },
{ name: 'COMPANY_NUM', index: '3', align: 'left', sortable: true },
{ name: 'CUSTOMER_NUM', index: '4', align: 'left', sortable: true },
{ name: 'LINK_NUM', index: '5', align: 'left', sortable: true },
{ name: 'PHONE_1', index: '6', align: 'left', sortable: true },
{ name: 'SALESREP_NUM', index: '7', align: 'left', sortable: true },
{ name: 'ADDRESS_SEQ_NUM', index: '8', align: 'left', sortable: true }
],
pager: navigation,
rowNum: 10,
rowList: [5, 10, 20, 30, 50],
viewrecords: true,
caption: '',
height: '250px',
sortorder: 'asc',
sortname: '0',
shrinkToFit: true,
autowidth: true,
}
})
};
The action method mentioned (/Customer/CustomerSearchInfo) is not getting called for the second time.
[AcceptVerbs(HttpVerbs.Post)] public ActionResult CustomerSearchInfo(string param, int type) {
try
{
var custInfo = new List<Customer>();
switch (type)
{
case 1:
custInfo = custDO.GetCustomerInfo(customerID: param);
break;
case 2:
custInfo = custDO.GetCustomerInfo(customerName: param);
break;
case 3:
custInfo = custDO.GetCustomerInfo(contactName: param);
break;
case 4:
custInfo = custDO.GetCustomerInfo(companyID: param);
break;
case 5:
custInfo = custDO.GetCustomerInfo(salesRepID: param);
break;
case 6:
custInfo = custDO.GetCustomerInfo(phone: param);
break;
case 7:
custInfo = custDO.GetCustomerInfo(addrtype: param);
break;
case 8:
custInfo = custDO.GetCustomerInfo(status: param);
break;
case 9:
custInfo = custDO.GetCustomerInfo(linkID: param);
break;
}
return custInfo != null
? Json(GetJson(custInfo, 10, custInfo.Count, 0),
JsonRequestBehavior.DenyGet)
: Json(null, JsonRequestBehavior.DenyGet);
}
catch (Exception ex)
{
Response.StatusCode = 500;
return Json(null, JsonRequestBehavior.DenyGet);
}
}
For reference below are the 2 search buttons:
input id="btnCustID" type="button" class="buttonsearch" title="Search BY Customer ID" onclick="LoadGrid(document.getElementById('txtCustID').value,1)"
input id="btnCustName" type="button" class="buttonsearch" title="Search BY Customer Name" onclick="LoadGrid(document.getElementById('txtCustName').value,2)"