I have some JQuery AJAX POSTing data to my backend C# WebForm. It POSTs to a static string WebForm method which returns a value, the JQuery uses that value to change an image url in the html. All is fine and dandy.
However, I would like to expand the functionality of the existing code (though I'm not shut out to rewriting it altogether) to allow me to manipulate the front end ASP controls from the C# backend, which I can not do due to the said static string method acting as my WebForm.
Does anyone have any ideas to help my predicament?
Backend
[System.Web.Services.WebMethod]
public static string ImageLoad(string address)
{
//if fail
return "/Unavailable.bmp";
//if succeed
return "myimage.jpg";
//third option
else
return "myotherimage.jpg";
}
JQuery/AJAX
function scriptImageLoad() {
var address = $("#txtAddress").val();
$.ajax({
type: "POST",
url: "myPage.aspx/ImageLoad",
data: "{'address':'" + address.toString() + "'}",
contentType: "application/json; charset=utf-8",
dataType: "text",
success: function (output) {
$('#imgImage').attr('src', output);
}
});
}
});