This rough idea of the modifying operation here is quite
similar to that in adding and deleting a tag category. First, the server side
page is RenameSection.aspx, whose behind code is listed below.
Listing 17
protected void Page_Load(object sender, EventArgs e)
{
if ((Request.Params["id"] != null) &&
(Request.Params["name"] != null))
{
// the tag category id to be modified
int iSectionId = Convert.ToInt32(Request.Params["id"]);
// the new web tag name
string strSectionName = Request.Params["name"];
// set up the database access object
Database db = DatabaseFactory.CreateDatabase
("DatabaseConnectionString");
// define the SP RenameSection related object
string sqlCommand = "RenameSection";
DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
// provide the input parameters for the SP
db.AddInParameter(dbCommand, "id", DbType.Int32, iSectionId);
db.AddInParameter(dbCommand, "name", DbType.String, strSectionName);
// execute the stored procedure
db.ExecuteNonQuery(dbCommand);
}
}
Here, the stored procedure RenameSection is invoked. And
also, we have to pass in the two related arguments id
and name which represent the id and the name property
of the modifying tag category respectively.
In contrast to the above, on the client side, we still
leverage "Ajax.Request" class to send out requests to page RenameSection.aspx,
whose script code is as follows.
Listing 18
function RenameSection(id) {
var sectionName = window.prompt("Please enter a new tag category name");
if (sectionName) {
var paras = "id=" + id + "&name=" + escape(sectionName);
new Ajax.Request("RenameSection.aspx", {
mothed: "GET",
parameters: paras,
onComplete: function(xmlhttp)
{
new Ajax.Request("ListSection.aspx",
{onComplete: InitSection});
}
});
}
}
Here, we first use the JavaScript window.prompt dialog to
let the user enter a new tag category name. Then, construct the parameter
passed to page RenameSection.aspx. And finally, asynchronously call page RenameSection.aspx
to accomplish the task of modifying the category name behind the scene.