Problem with a String

LiLo

Freshman
Joined
Mar 10, 2006
Messages
33
Hi, I am using C# to call a javascript function. A string represents the name of the javascript function. Below is a snippet of the 'before' and 'after' operations.

The original c# code is :
C#:
private const string AttachContextMenu = "return __showContextMenu({0});"; //this is the string which represents the javascript function

//then I use string.format on the string constant
public string GetMenuReference()
{
return String.Format(AttachContextMenu, Controls[0].ClientID);
}

//finally, the javascript is called upon the 'oncontextmenu' event
ctl1.Attributes["oncontextmenu"] = GetMenuReference();
But when I changed the GetMenuReference() method to the following,
C#:
return String.Format("return _showContextMenu({0});",Controls[0].ClientID);

the javascript function does not work anymore!! All I did was to replace the const variable with the actual string itself. How come it doesnt work already? :confused:
 
Last edited by a moderator:
why you changed value of string:
"return __showContextMenu({0});"
to
"return _showContextMenu({0});"
look at _ and fix it.
 
Back
Top