protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // Get the index of the book to update
                index = Convert.ToInt32(Request.QueryString["bookId"]);

                // Get the record and save it in viewstate
                bookToUpdate = BBooks.getById(index);
                ViewState["bookToUpdate"] = bookToUpdate;

                // Load Section dropDownList
                ddlSection.DataSource     = BSection.getAll();
                ddlSection.DataTextField  = "Name";
                ddlSection.DataValueField = "SectionId";
                ddlSection.DataBind();

                // Fill the textBoxes
                boxTitle.Text            = bookToUpdate.Title;
                boxAuthor.Text           = bookToUpdate.Author;
                ddlSection.SelectedValue = bookToUpdate.SectionId.ToString();

                boxIbsn.Enabled = false;
                boxIbsn.Text    = bookToUpdate.Ibsn.ToString();
            }
        }
        protected void boxIbsn_TextChanged(object sender, EventArgs e)
        {
            // Enable Fields
            boxTitle.Enabled = true;
            //boxTitle.Text = "";

            boxAuthor.Enabled = true;
            //boxAuthor.Text = "";

            ddlSection.Enabled = true;

            // Validate text field
            literalIbsn.Text = "";
            int value;

            if (!int.TryParse(boxIbsn.Text, out value))
            {
                literalIbsn.Text = writeDigitsLabel();
            }

            // If textBox contains data and is a number it does the logic
            if (!string.IsNullOrEmpty(boxIbsn.Text) && int.TryParse(boxIbsn.Text, out value))
            {
                int ibsnToCheck = Convert.ToInt32(boxIbsn.Text);
                int bookId      = BBooks.ibsnExist(ibsnToCheck);
                // If ibsn exist, some controls are filled and ibsn is blocked
                if (bookId > 0)
                {
                    // Get the book record
                    Books book = new Books();
                    book = BBooks.getById(bookId);

                    // Book: Fill fields and diable them
                    boxTitle.Enabled = false;
                    boxTitle.Text    = book.Title;

                    boxAuthor.Enabled = false;
                    boxAuthor.Text    = book.Author;

                    ddlSection.Enabled       = false;
                    ddlSection.SelectedValue = book.SectionId.ToString();
                }
            }
        }