Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (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 by PlausiblyDamp

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...