Compared with other functionalities, removing a web tag is
easy, which is performed using the following steps. First, write the
behind-code page to invoke the stored procedure DeleteNote. Next, use page
DeleteNote.aspx to implement the tag removing function. Listing 12 gives the
related behind code.
Listing 12
protected void Page_Load(object sender,
EventArgs e)
{
if (Request.Params["id"] != null)
{
// tag id
int iNoteId = Convert.ToInt32(Request.Params["id"]);
// set up the database access object
Database db = DatabaseFactory.CreateDatabase
("DatabaseConnectionString");
// the SP DeleteNote to delete tags
string sqlCommand = "DeleteNote";
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);
}
}
Since there are already enough comments herein, you can
easily seize the main idea of it. One note is the passed argument of page
DeleteNote.aspx, i.e. the tag id.
As regards the "Delete" tag button, it has already
been implemented when we discuss displaying the tag category list. And also, we
have already provided the corresponding onclick event response function, DeleteNote(),
is as follows.
Listing 13
// Delete Tag
function DeleteNote(id) {
if (confirm("Are you sure to delete current tag? Not you cannot undo it!")) {
new Ajax.Request("DeleteNote.aspx", {
mothed: "GET",
parameters: "id=" + id,
});
}
}
// Delete tag list
function RefreshNoteList() {
var section_id = $("selSection").value;
new Ajax.Request(
"ListNotes.aspx", {
parameters: "sid=" + section_id,
onComplete: ShowNotes
}
);
}