私はjQueryの初心者であり、PageMethodの結果をjQueryスクリプトに読み込もうとしています。ScriptManagerがインストールされており、次のWebMethodがあります。
[WebMethod(EnableSession = true)]
public static string CheckSystemDefault(string _id)
{
int id = Convert.ToInt16(_id);
addressTypeRepository = new AddressTypeRepository();
AddressType addressType = addressTypeRepository.GetById(id);
if (addressType.IsSystemDefault == true)
return "IsSystemDefault";
else
return "IsNotSystemDefault";
}
これを使用して、オブジェクトにプロパティIsSystemDefaultがあるかどうかを確認します。
スクリプトでは、URLからIDを渡し、結果を評価したいと思います。
var id = $(document).getUrlParam("id");
var check = PageMethods.CheckSystemDefault(id);
if (check == "IsSystemDefault") {
...
}
if (check == "IsNotSystemDefault") {
...
}
しかし、その結果、変数「check」は未定義です。何を変更する必要がありますか?