Are you looking for a convenient way to return values (contents) from the server to the client and you don't want the overhead of a complete page?
Try HttpHandler.
public class Your_Handler : IHttpHandler
{
private HttpContext _yourContext;
public void ProcessRequest (HttpContext context)
{
_yourContext = context;
_yourContext.Response.ContextType = "text/html";
Your_Method();
}
public void Your_Method()
{
_yourContext.Response.Write("<p> VALUES </p>");
}
}
To consume it, you can use AJAX like this:
$.ajax ({
type: "GET",
url: "Your_Handler.ashx",
cache: false,
success: function (html) {
$(":#YourId").append(html);
},
error: function (html) {
$("YourId").append("<p> Error on server. </p>");
}
});
No comments:
Post a Comment