I have this client-side:
$(document).ready(function() {
var $checkboxes = $('[type=checkbox]');
$checkboxes.click(function() {
$checkbox = $(this);
$.ajax({
type: "POST",
开发者_开发问答 url: "Page.aspx/Method",
data: "{id:'" + $checkbox.attr("id") + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
alert('success!');
},
error: function(xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
alert('An error occurred that prevented your change being saved: ' + err.Message);
}
});
});
});
And I have this server-side:
[WebMethod]
public static void Method(String id)
{
Guid guidID = new Guid(classid));
//...........
}
But I'd prefer to make the WebMethod signature strongly typed:
[WebMethod]
public static void Method(Guid id)
{
//...........
}
Can you advise what is the best way to do this?
I think you can pass the Guid as a string into your method and it should convert it. check this out
You can have strongly typed parameter(s). If they're in the correct format, they'll be implicitly converted to the correct type upon hitting the method.
精彩评论