LiLo Posted March 27, 2006 Posted March 27, 2006 (edited) 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 : 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, 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: Edited March 27, 2006 by PlausiblyDamp Quote
hamid Posted March 28, 2006 Posted March 28, 2006 why you changed value of string: "return __showContextMenu({0});" to "return _showContextMenu({0});" look at _ and fix it. Quote [ once4ever ]
LiLo Posted March 28, 2006 Author Posted March 28, 2006 yup,the problem lies with the extra underscore Thanks! :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.