Build an AJAX Based ASP.NET Web Tag Application - Part 2
page 5 of 12
by Xianzhong Zhu
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 45404/ 136

Removing a Web Tag

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
        }
    );
}

View Entire Article

User Comments

Title: Thanks   
Name: Cong Doan
Date: 2009-04-13 11:17:25 AM
Comment:
Thanks for your Article! It's wonderful!






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-05-18 11:02:37 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search