<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AsynchrousSave.aspx.cs" Inherits="DUMMY_AsynchrousSave" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type='text/javascript'>
function GetMessage() {
PageMethods.Message(OnGetMessageSuccess, OnGetMessageFailure);
}
function OnGetMessageSuccess(result, userContext, methodName) {
alert(result);
}
function OnGetMessageFailure(error, userContext, methodName) {
alert(error.get_message());
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID='ScriptManager1' runat='server' EnablePageMethods='true' />
<div>
<input type='submit' value='Get Message' onclick='GetMessage();return false;' />
</div>
</form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class DUMMY_AsynchrousSave : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[System.Web.Services.WebMethod]
public static string Message()
{
string Output = string.Empty;
try
{
UserDetail objUserDetail = new UserDetail();
objUserDetail.Id = Guid.NewGuid();
objUserDetail.FirstName = "FirstName";
objUserDetail.LastName = "LastName";
objUserDetail.Email = "test@test.com";
UserDetailProvider.Save(objUserDetail);
Output = "Message Successfull";
}
catch (Exception ex)
{
Output = "Message Not Successfull";
}
return Output;//"Hello from the server-side World!";
}
}
0 comments:
Post a Comment