I've just start working with handlers in asp.net and I've got one question. I have PostRequestPage.aspx page with such structure:
<asp:Label ID="lblTest" Text="Enter request" runat="server"></asp:Label>
<br />
<asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
<br />
<span id="error"></span>
<br />
<input type="button" id="btnSubmit" name="btnSubmit" value="Send" />
And I send my POST to handler using ajax post like this:
$(document).ready(function () {
$('#btnSubmit').click(function() {
var txtEmail = '<%=txtEmail.ClientID%>';
$.ajax({
type: "POST",
url: "HandlerWithPOST.ashx",
data: $('#' + txtEmail).val(),
dataType:"json",
});
});
})
In handler I get my POST data:
using (var reader = new StreamReader(context.Request.InputStream))
{
String requestFromPost = reader.ReadToEnd();
var result = JsonConvert.DeserializeObject<List<RootObject>>(requestFromPost);
}
Then I process my data and get the response I want to return to PostRequestPage.aspx page :
String jsonResult = JsonConvert.SerializeObject(new { result = results });
The question is how can I show my jsonResult in label,for example?