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);
}
});
}
});
With the help of a colleague, I developed a different solution. A structure holds the output data I desire, it is then transfered into a string array, then returned via the static string web method. Once returned to the Jquery, the data is pushed to where it needs to go by the different indexes of the array.
Front end
Back end
Now the only issues I have is getting the Jquery to properly display the data to the client.