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

Removing a Web Tag Category

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
            // 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

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.

View Entire Article

User Comments

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

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

©Copyright 1998-2024  |  Page Processed at 2024-05-28 10:48:05 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search