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 :
But when I changed the GetMenuReference() method to the following,
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?
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();
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?
Last edited by a moderator: