Hi all,

I'm trying to translate a piece of CFM code into .NET and since I'm not very familiar with it I'm getting more and more entangled along the way because of the way C# & NET handle arrays and pass variable values through HTML.

What I need to do it's pretty simple, I have a "sticky" javascript rollover navigation include that desactivates the "OFF" state of a navigation item depending on which section the user finds himself, it basically highlights the section you're in.

No problems so far but what I need to do before the navigation even loads is to assign Array values to both the image file name and the "mouse state" so as to be able to have a section's corresponding navigation graphic on its "ON" state before the mouse even goes near it.

This "ON" state is activated thanks to a "SectionVar" Section variable that tells the navigation where you are. This variable needs to be available to both the javascript & C# code for both require its value to active the rollover state.


So my first question is How do you pass a C# variable value into javascript?

Secondly I have tried several ways of translating my old CFM code into the new C#, but there seems to be a problem in the way it handles arrays and I keep getting "vague" errors which do not tell me what is wrong with the code below i.e. "} expected, when it isn't"... etc..


<%@ Page Language="C#" runat="server"%>
<script language="c#" runat="server">
private void Page_Load(object sender, System.EventArgs e){
//defines initial array for navigation the first time it loads

using System;

class FindWhatSection{

//This is the variable which tells you were you are
string SectionVar = "Home";

FindWhatSection()
{
//Mouse State variable
protected string MseState;

//Two dimensional navigation items array
protected string[,] NavItem;

//The mouse state, set to OFF by default
MseState = "off";
NavItem = new string[4,2];


NavItem[0,0]="Home";
NavItem[0,1]=MseState;


NavItem[1,0]="AboutUs";
NavItem[1,1]=MseState;


NavItem[2,0]="History";
NavItem[2,1]=MseState;

NavItem[3,0]="CaseStudies";
NavItem[3,1]=MseState;

NavItem[4,0]="Contact";
NavItem[4,1]=MseState;

for(int i = 0; i<NavItem.Length; i++){
if (SteLocation[9,MseState]==SectionVar){
SteLocation[9,MseState]="on";
}
}
}
}

#####

<!--example of resulting HTML, ignore rollover code-->
<td><a href="/home.aspx" onmouseover="changeTo('home')" onmouseup="changeBack('home')" onmouseout="changeBack('Introduction')" onclick="setVar('home')"><img src="/images/nav_<%=NavItem[0,0]%>_<%=NavItem[0,1]%>.gif" width="100" height="50" name="Home" alt="Home" border="0"></a></td>


How do you search for a column value specifically with a loop in C# as in above? I need to find the array position "Home" and change its Mstate column value to "ON".

And this is another problem I came accross in .NET. I was using the old ASP "<%=" syntax to call the variable value, it does not seem to recognise it in .NET, what is the alternative?

If anyone could please give me some clues as to why the code above doesn't work I would be very grateful!

Regards