When you click the "Delete current tag category"
menu item, a simple alert dialog box will pop up asking you whether you are
sure to make the deletion. After you press "Yes" and delete the
current tag category, the tag category list will be automatically updated.
The behind code relating to page DeleteSeciton.aspx is shown
below.
Listing 15
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Params["id"] != null)
{
// the tag category id to be deleted
int iNoteId = Convert.ToInt32(Request.Params["id"]);
// set up the database access object
Database db = DatabaseFactory.CreateDatabase
("DatabaseConnectionString");
// define the SP DeleteSection related object
string sqlCommand = "DeleteSection";
DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
// provide the input parameters for the SP
db.AddInParameter(dbCommand, "id", DbType.Int32, iNoteId);
// execute the stored procedure
db.ExecuteNonQuery(dbCommand);
}
}
Herein, the argument id passed to
page DeleteSection.aspx represents the id attribute of the tag category to be
deleted.
On the client side, the similar means is taken to invoke the
page DeleteSection.aspx in the asynchronous way, which is indicated in the
following scripts.
Listing 16
function DeleteSection(id) {
if (window.confirm("Are you sure to delete current tag category? All the
tag info with it will be removed and cannot be restored!")) {
var paras = "id=" + id;
new Ajax.Request("DeleteSection.aspx", {
mothed: "GET",
parameters: paras,
onComplete: function(xmlhttp)
{
new Ajax.Request("ListSection.aspx",
{onComplete: InitSection});
}
});
}
}
Next, let us shift our attention to the web tag category
modification operation.