Jquery at the front end:
$.ajax({ type: "POST", contentType: "application/json; charset=utf-8", dataType: "json", url: "SjgBackheadSendEdit.aspx/IsReadOnly", data: "{'strOID':'" + oid + "'}", success: function (result) { if (result.d == "True") { if ($("select[id$='ddlLevelType']")) { $("select[id$='ddlLevelType']").next('input').attr('class', 'contentEditableSelect ui-corner-all ui-widget-content'); $("select[id$='ddlLevelType']").next('input').next('button').attr('disabled', 'disabled'); $("select[id$='ddlLevelType']").next('input').next('button').attr('class', 'ui-button ui-widget ui-state-default ui-button-icon-only ui-corner-right ui-button-icon contentEditableSelectInput'); } } }, error: function (xhr) { var err = eval("(" + xhr.responseText + ")"); alert(err.Message); } });
Method called in the background: [webmethod] must be marked and the method must be static
[WebMethod] public static string IsReadOnly(string strOID) { string strResult = string.Empty; var presenter = new SjgBackheadSendEditPresenter(null); strResult = presenter.IsReadOnly(strOID).ToString(); return strResult; }