Implementing an Ajax Live Form with NetAdvantage WebClient Controls - Codebehind

Craig Shoemaker / Friday, November 21, 2008

The following listing the the C# code for Implementing an Ajax Live Form with NetAdvantage WebClient Controls

using System;
using System.Web.Services;
 
public partial class Composite_LiveForm_Default : System.Web.UI.Page
{
    protected Book book = null;
 
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.Page.IsPostBack)
        {
            this.book = BookRepository.Instance.GetByID(1);
            this.txtTitle.Text = this.book.Title;
            this.wdcPublishDate.Value = this.book.PublishDate;
        }
    }
 
    [WebMethod]
    public static bool UpdateTitle(int id, string title)
    {
        try
        {
            System.Threading.Thread.Sleep(3000);
            Book b = BookRepository.Instance.GetByID(id);
            b.Title = title;
            BookRepository.Instance.Update(b);
            return true;
        }
        catch (Exception ex)
        {
            // publish exception
            System.Diagnostics.Debug.WriteLine(ex.Message);
            return false;
        }
    }
 
    [WebMethod]
    public static bool UpdatePublishDate(int id, DateTime publishDate)
    {
        try
        {
            System.Threading.Thread.Sleep(3000);
            Book b = BookRepository.Instance.GetByID(id);
            b.PublishDate = publishDate;
            BookRepository.Instance.Update(b);
            return true;
        }
        catch (Exception ex)
        {
            // publish exception
            System.Diagnostics.Debug.WriteLine(ex.Message);
            return false;
        }
    }
}