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

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
              ("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.


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-03-28 10:15:09 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search