Necuno
Court Jester
- Joined
- Sep 27, 2005
- Messages
- 58,567
...going through roughly 4 years back of how i coded its scary to say the least lol
ex
or
ex
Code:
/// <summary>
/// setup all the controls on the page.
/// </summary>
private void SetupControls()
{
string PageName = Request["PageName"];
string[] sButtons;
switch (PageName)
{
case "Current Service Providers":
case "View Projects":
{
string PageLocation = GetLocation(PageName);
//create string array with the buttons names in the order that they should appear on the bottom bar
sButtons = new string[4] { "First", "Last", "Next", "Previous" };
SetupNavButtons(sButtons);
SetupPageName(PageName);
SetupBusyWith(null);
SetupOnclicks(sButtons, "GridViewNavEvent('" + PageLocation + "',this.value);return false");
break;
}
case "Update User":
case "New User":
case "Update Project":
case "New Project":
{
string PageLocation = GetLocation(PageName);
//create string array with the buttons names in the order that they should appear on the bottom bar
if (PageName.IndexOf("New") > -1) { sButtons = new string[3] { "Previous", "Next", "Cancel" }; }
else { sButtons = new string[2] { "Update", "Return" }; }
SetupNavButtons(sButtons);
SetupPageName(PageName);
SetupBusyWith("");
SetupOnclicks(sButtons, "MultiViewNavEvent('" + PageLocation + "',this.value);return false");
if (PageName.IndexOf("New") > -1) { SetupCCS("Cancel", "ButtonCancel"); }
break;
}
case "Test":
{
//create string array with the buttons names in the order that they should appear on the bottom bar
sButtons = new string[4] { "Next", "Previous", "First", "Last" };
SetupNavButtons(sButtons);
SetupPageName(PageName);
SetupBusyWith("");
SetupOnclicks(sButtons, "MultiViewNavEvent(this.value);return false");
break;
}
case "Project":
case "Report Viewer":
case "Report Viewer SEP":
case "Reports New":
case "Report Viewer MPR":
case "Outstanding MPR":
case "User Details":
case "Current Users":
case "Reports":
case "Project Personnel":
case "Cashflow":
case "Claims":
case "Add/Edit Claim":
case "Claim Budget":
case "Consultant Claim":
case "Contractor Claim":
case "Cheque Request":
case "Report Project":
case "Project KPI":
case "Project Service Provider":
{
SetupPageName(PageName);
SetupBusyWith(null);
break;
}
case "Add Service Provider":
case "Edit Service Provider":
case "Service Provider Owner":
case "Service Provider Person":
//case "Add/Edit Claim":
{
string PageLocation = GetLocation(PageName);
//create string array with the buttons names in the order that they should appear on the bottom bar
sButtons = new string[2] { "Save", "Cancel" };
SetupNavButtons(sButtons);
SetupPageName(PageName);
SetupBusyWith(null);
SetupOnclicks(sButtons, "BtnEvent('" + PageLocation + "',this.value);return false");
SetupCCS("Cancel", "ButtonCancel");
break;
}
//case "Project":
// {
// string PageLocation = GetLocation(PageName);
// //create string array with the buttons names in the order that they should appear on the bottom bar
// sButtons = new string[1] { "KPI" };
// SetupNavButtons(sButtons);
// SetupPageName(PageName);
// SetupBusyWith(null);
// SetupOnclicks(sButtons, "BtnEvent('" + PageLocation + "',this.value);return false");
// //SetupCCS("Cancel", "ButtonCancel");
// break;
// }
default:
{
//null
break;
}
}
}
or
Code:
/// <summary>
/// builds all the sub navigational links
/// </summary>
/// <param name="PageName">name of the page to get links for</param>
//private void BuildSubNavLinks(string PageName)
//private void BuildSubNavLinks(string PageName, string ID)
private void BuildSubNavLinks(string PageName, string ID, string ID2, string ID3)
{
//genTopNavBar NewSubNavLinks = new genTopNavBar();
genTopNavBar NewSubNavLinks;
//if (ID == "undefined")
////use normal constructor without ID
//{
// NewSubNavLinks = new genTopNavBar();
//}
////else use constructor with ID
//else if (ID2 == "undefined")
//{
// NewSubNavLinks = new genTopNavBar(ID);
//}
//else if (ID3 == "undefined")
//{
// NewSubNavLinks = new genTopNavBar(ID, ID2);
//}
//else
//{
// NewSubNavLinks = new genTopNavBar(ID, ID2, ID3);
//}
if (ID == null)
//use normal constructor without ID
{
NewSubNavLinks = new genTopNavBar();
}
//else use constructor with ID
else if (ID2 == null)
{
NewSubNavLinks = new genTopNavBar(ID);
}
else if (ID3 == null)
{
NewSubNavLinks = new genTopNavBar(ID, ID2);
}
else
{
NewSubNavLinks = new genTopNavBar(ID, ID2, ID3);
}
//use if to check if ID is null - if not then pass to the constructor
//if null then use normal constructor
string[,] SubNavLinks = NewSubNavLinks.SubNavLinks(PageName);
if (SubNavLinks != null)
{
int TotalLinks = SubNavLinks.Length / 3; // 2d, 3part string array. Name, Url, Position
for (int i = 0; i < TotalLinks; i++)
{
string hlnkID = "hlnkSub" + SubNavLinks[i, 2]; //gets the position, makes up control ID
HyperLink CurrentHyperLink = (HyperLink)Page.FindControl(hlnkID);
CurrentHyperLink.Text = SubNavLinks[i, 0]; //NAME
CurrentHyperLink.NavigateUrl = SubNavLinks[i, 1]; //URL, //add any ID here if needed !
// We want documentation to open in a new window, so if
// this is the docs link, we give it a special target
if (CurrentHyperLink.Text != "Documentation")
CurrentHyperLink.Target = "frmBody";
else
CurrentHyperLink.Target = "_new";
CurrentHyperLink.Visible = true;
}
}
}
Last edited: