Unable to call JavaScript on Action Menu Items
<p>I am new to JavaScript.</p>

<p>In my code behind I have this code block:</p>

<pre><code>if (!Page.IsCallback)
 {
  List&lt;String&gt; itemIds = new List&lt;string&gt;();
  itemIds.Add(DELETE_ACTION);

  this.Page.ClientScript.RegisterStartupScript(GetType(), "SetItemClickConfirmJS",
                    SetItemClickConfirmJS(itemIds, DELETE_CONFIRM_MSG), true);
 }
</code></pre>

<p>The function I am using is as follows :</p>

<pre><code> private string SetItemClickConfirmJS(List&lt;String&gt; itemIds, string message)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("function addItemClickConfirm(menuId, itemId)");
            sb.Append("{");
            //sb.Append("    debugger;");
            sb.Append("    var item = igmenu_getItemById(itemId);");
            sb.Append("    var menu = igmenu_getMenuById(menuId);");

            sb.Append("    switch(item.getText())");
            sb.Append("    {");
            foreach (string itemId in itemIds)
            {
                sb.AppendFormat("    case '{0}':", itemId);
                sb.Append("    {");
                sb.AppendFormat("        if(confirm('{0}'))", message);
                sb.Append("        {");
                sb.Append("            Menu_ItemClick(menuId, itemId)");
                sb.Append("        }");
                sb.Append("        else");
                sb.Append("        {");
                sb.Append("            menu.NeedPostBack = false;");
                sb.Append("            menu.CancelPostBack = true;");
                sb.Append("        }");
                sb.Append("        break;");
                sb.Append("    }");
            }
            sb.Append("    default: ");
            sb.Append("       Menu_ItemClick(menuId, itemId)");
            sb.Append("    }");
            sb.Append("}");

            return sb.ToString();
        }
</code></pre>

<p>When I click on the Menu Button a message pops up but when I click on the OK button on that Popup message block I get the following error</p>

<p>[FormatException: String was not recognized as a valid Boolean.]</p>

<p>. Please help.</p>

<p>Thanks!</p>
