In the ASP.NET Portal Starter Kit, you select the specified item in the list box, and you can implement the sorted function (as shown below) by clicking the up and down button.
Usually what I think is (above the move as an example): Get the sort number of the selected item and the sequence number of the previous sequence number of the selected item, and exchange their sort number. The order of the sequence number is in the form of 1, 2, 3, 4 ..., and the serial number of the newly created label is added to the last basis. The way to be taken in the ASP.NET Portal Starter Kit is to indicate the sequence number by 1, 3, 5, 7 ..., and the sequence number is re-constructed each time. When moving up, the current rapper number is reduced by 3, so the new sequence number is in front of it, and behind the upper two. For example: shifting the 7th place, then the new order is 1, 3, 4, 5, 9.
The code is as follows (some code, detailed to see the code in tabs.ascx.cs):
// Move downward code
IF (TabList.SelectedIndex! = -1)
{
Int delta;
// Because the label sequence number is arranged in 1, 3, 5, 7, and 9
// Move a tag or down, add the label serial number to 3, just in front of the front and rear, one.
// If you move the seventh place, then the new order is 1, 3, 4, 5, 9
IF (cmd == "down"))
{
Delta = 3;
}
Else
{
DELTA = -3;
}
Tabitem T;
T = (TabItem) PortalTabs [TabList.SelectedIndex];
T. Taborder = DELTA;
/ / Re-order the new sequence number
Ordertabs ();
}
///
/// Sort the label in PortalTabs
/// summary>
Private void ORDERTABS ()
{
INT i = 1;
// Use the specified comparator to sort the elements in the part system.collections.arraylist.
The object in the portalTabs is TabItem, the TabItem object inherits the IComparable interface, implements the Taborder's Compareto
Portaltabs.sort ();
// Renumber the Order and Save to DataBase
// Store the sorted information into XML
Foreach (TabItem Tin PortalTabs)
{
// Alternatively arrange the sequence number of the label to 1, 3, 5, incremented order
T.taborder = i;
i = 2;
// write new sequence number to user profile
CONFIGURATION CONFIG = New Configuration ();
Config.UpdateTaborder (t.tabid, t.taborder);
}
}
This method is actually not good, it can only be a new idea. Every time you want to update the user profile each time, I don't think it is better to update the user profile after the exchange number is exchanged. However, in the way in the exchange number, it is necessary to determine whether the item is selected as the first item (cannot be moved) or the last item (cannot be moved). Moreover, there are also the management items as the last request, and use the exchange number may write a lot of code. There may be other benefits, I didn't think of it, so weigh the pros and cons or use his method! By the way, it seems that the program provided by default cannot achieve the function of moving downward, I don't know if everyone has encountered. To modify the SaveSitSettings () method in the configuration.cs file, the modified code:
Public void savesitsettings ()
{
// Original: Get the site setting information data set from cache (it seems to be a bug, because each update data is updated in httpContext.current.Items)
// Siteconfiguration Sitesettings = (SiteConfiguration) httpContext.current.cache ["Sitesettings"];
// after edited
SiteConfiguration SiteSettings = (SiteConfiguration) httpContext.current.Items ["Sitesettings"];
// If there is no Cache, it is rebuilt
IF (Sitesettings == Null)
{
// if SavesiteSettings () is Called Once, The Cache Is Cleared. IF IT IS
// then called again before global.application_beginRequest is Called,
// Which Reloads the cache, The Sitsettings Object Will Be Null
// (This sentence does not know the translation is wrong, it seems important) If SaveSitSettings () is called once, Cache is cleared back. If it is called again in Global.Application_BeginRequest, SitESETTINGS is rewriting Cache
Sitesettings = getSitSettings ();
}
String configfile = httpcontext.current.server.mappath (configurationSettings.appsettings ["configfile"]);
// Object is evicted from the cache here.
// Write the changed data set to the XML file
Sitesettings.writexml;
}
More related content: Click here >>