Click here to Skip to main content
15,913,465 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Clever Coder or Annoying SmartAss? Pin
StM0n29-Jul-11 0:32
StM0n29-Jul-11 0:32 
GeneralRe: Clever Coder or Annoying SmartAss? Pin
Caslen29-Jul-11 0:49
Caslen29-Jul-11 0:49 
GeneralRe: Clever Coder or Annoying SmartAss? Pin
StM0n29-Jul-11 0:55
StM0n29-Jul-11 0:55 
GeneralRe: Clever Coder or Annoying SmartAss? Pin
BobJanova29-Jul-11 5:43
BobJanova29-Jul-11 5:43 
GeneralRe: Clever Coder or Annoying SmartAss? Pin
richard_k3-Aug-11 16:53
richard_k3-Aug-11 16:53 
GeneralRe: Clever Coder or Annoying SmartAss? Pin
Caslen5-Aug-11 2:09
Caslen5-Aug-11 2:09 
GeneralRe: Clever Coder or Annoying SmartAss? Pin
thoiness1-Sep-11 5:09
thoiness1-Sep-11 5:09 
GeneralComma operator considered harmful Pin
o m n i27-Jul-11 12:42
o m n i27-Jul-11 12:42 
GeneralRe: Comma operator considered harmful Pin
Al_Brown27-Jul-11 22:06
Al_Brown27-Jul-11 22:06 
GeneralRe: Comma operator considered harmful Pin
oggenok6428-Jul-11 0:08
oggenok6428-Jul-11 0:08 
GeneralRe: Comma operator considered harmful Pin
BillW3328-Jul-11 4:03
professionalBillW3328-Jul-11 4:03 
GeneralRe: Comma operator considered harmful Pin
BobJanova29-Jul-11 5:39
BobJanova29-Jul-11 5:39 
GeneralHall of Shame Pin
VE226-Jul-11 3:52
VE226-Jul-11 3:52 
GeneralRe: Hall of Shame Pin
Peter_in_278026-Jul-11 14:50
professionalPeter_in_278026-Jul-11 14:50 
GeneralRe: Hall of Shame Pin
Dalek Dave27-Jul-11 23:01
professionalDalek Dave27-Jul-11 23:01 
GeneralRe: Hall of Shame Pin
Peter_in_278028-Jul-11 0:02
professionalPeter_in_278028-Jul-11 0:02 
GeneralRe: Hall of Shame Pin
TorstenFrings28-Jul-11 3:23
TorstenFrings28-Jul-11 3:23 
GeneralHow to generate a menu [modified] PinPopular
Keith Barrow24-Jul-11 21:50
professionalKeith Barrow24-Jul-11 21:50 
This is the loop that generates our main menu , all on one line:
XML
<%   int i = 1; foreach (Fatthallah.Web.HttpHandler.PetraMainMenu mainMenuItem in mainMenuCollection) { Response.Write("<li style=\"float:" + (lang == "en" ? "left" : "right") + "\"><a  id =\"a" + i + "\" name=\"a" + i + "\" href=\"" + (mainMenuItem.MainMenuLink.Trim().Length > 0 ? ResolveUrl("~/" + mainMenuItem.MainMenuLink.Split('?')[0] + "lang=" + lang + "&" + mainMenuItem.MainMenuLink.Split('?')[1]) : "javascript:void(0)") + "\" onclick=\"fetchData('menuHandler.axd','hml','menu=true&id=" + mainMenuItem.MainMenuId + "&lang=" + lang + "',this);return false;\" onmouseout=\"hidebox(this);\" >" + (mainMenuItem.MainMenuTitleEnglish.Trim().Length > 0 && lang == "en" ? mainMenuItem.MainMenuTitleEnglish : mainMenuItem.MainMenuTitleArabic) + "</a></li>"); i++; } Response.Write("<script language='javascript' type='text/javascript'>mainMenuCounter =" + mainMenuCollection.ToArray().Length + "; var rtl=" + (lang == "en" ? "false" : "true") + ";</script>"); %>


My eyes are bleeding, and that's before I start the rant about how we keep our site bilingual and why we use JavaScript to replace what could be achieved with hyperlinks. Mad | :mad:
[Edit]

After a simple tidying exercise:

<%   
int i = 1; 
foreach (Fatthallah.Web.HttpHandler.PetraMainMenu mainMenuItem in mainMenuCollection) 
{
    Response.Write("<li style=\"float:" 
    + (lang == "en" ? "left" : "right") 
    + "\"><a  id =\"a" + i 
    + "\" name=\"a" + i 
    + "\" href=\""  + (mainMenuItem.MainMenuLink.Trim().Length > 0 ? ResolveUrl("~/" + mainMenuItem.MainMenuLink.Split('?')[0] 
    + "lang=" + lang 
    + "&amp;" + mainMenuItem.MainMenuLink.Split('?')[1]) : "javascript:void(0)") + "\" onclick=\"fetchData('menuHandler.axd','hml','menu=true&amp;id=" + mainMenuItem.MainMenuId 
    + "&amp;lang=" + lang + "',this);return false;\" onmouseout=\"hidebox(this);\" >" 
    + (mainMenuItem.MainMenuTitleEnglish.Trim().Length > 0 && lang == "en" ? mainMenuItem.MainMenuTitleEnglish : mainMenuItem.MainMenuTitleArabic) 
    + "</a></li>"); 
    i++; 
} 
Response.Write("<script language='javascript' type='text/javascript'>mainMenuCounter =" + mainMenuCollection.ToArray().Length + "; var rtl=" + (lang == "en" ? "false" : "true") + ";</script>"); 
%>

I think it was put on one line "keep our pages small" by removing unecessary whitespace, but this is code to generate html so it doesn't count. In any case it is still 100 times more complicated and convoluted than it needs to be for our purposes.

GeneralRe: How to generate a menu Pin
StM0n29-Jul-11 9:44
StM0n29-Jul-11 9:44 
GeneralRe: How to generate a menu Pin
the headless nick3-Aug-11 23:39
professionalthe headless nick3-Aug-11 23:39 
GeneralRedundancy Pin
Rob Grainger20-Jul-11 0:08
Rob Grainger20-Jul-11 0:08 
GeneralRe: Redundancy Pin
RobCroll20-Jul-11 2:16
RobCroll20-Jul-11 2:16 
GeneralTo Self-Close the BR or Not to Close the BR PinPopular
AspDotNetDev15-Jul-11 8:54
protectorAspDotNetDev15-Jul-11 8:54 
JokeRe: To Self-Close the BR or Not to Close the BR PinPopular
StM0n15-Jul-11 20:11
StM0n15-Jul-11 20:11 
GeneralRe: To Self-Close the BR or Not to Close the BR Pin
Jeroen De Dauw16-Jul-11 6:58
Jeroen De Dauw16-Jul-11 6:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.