0

I know this has been asked before and I've tried to use those solutions against my error, but I cannot get it to work using the solutions to past similar questions. The error message is that it expects a ')' . I've tried adding and removing parenthesis as well as removing single and double quotes but it still errors out each time?

protected void btnTestCS_Click(object sender, EventArgs e)
{

string result1 = "Failed: The samAccountName IdentityType must be in the form \"domainname\\userName\", \"machinename\\userName\", or \"userName\". | NN-NN-NN-01.NN.NN.NNNNN.NNN | CN=^sharing,OU=xxx_xxxxxx,OU=xxxxx,OU=xxxx,OU=xxx,OU=xxxxx,DC=xx,DC=xx,DC=xxx,DC=xxxxx)";
ScriptManager.RegisterStartupScript(Page, this.GetType(), "errorRunExchangeShellMultiCommandsss", "javascript:showDialogError(" + result1 + ")" , true);

}

    function showDialogError(results) {
        results = results.replace("'", "\\'");
        results = results.replace("\"", "");
        $("#dialogFailureText").text(results);
        $("#dialogFailure").dialog({
            modal: true,
            title: 'Something went wrong',
            text: results,
            buttons: {
                OK: function () {
                    $(this).dialog("close");
                }
            }


        });
    }
1
  • Looks like you're missing an opening '(' in your result1 string, but have ')' at the end of the string. Commented Jun 26, 2018 at 13:09

3 Answers 3

2

Your actual JS code is fine, the code you are injecting is missing a closing bracket though

"...showDialogError(" + result1 + ")", true)
Sign up to request clarification or add additional context in comments.

3 Comments

Believe it or not it still fails when I have that parenthesis as in your example. The debugger fails at this line. javascript:showDialogError(Failed: The samAccountName IdentityType must be in the form "domainname\userName", "machinename\userName", or "userName". | xx-xx-xx-xx.xx.xx.xxxxx.xxx | CN=^xxx5,OU=xxxx_xxxx,OU=xxx,OU=xxx,OU=xxx,OU=xxx xxxx,DC=xx,DC=xxx,DC=xxxxx,DC=xxx)//]]> The actual error text is: (next post)
Failed: The samAccountName IdentityType must be in the form "domainname\userName", "machinename\userName", or "userName". | xx-xx-xx-xx.xx.xx.xxxxx.xxx | CN=^xxx5,OU=xxxx_xxxx,OU=xxx,OU=xxx,OU=xxx,OU=xxx xxxx,DC=xx,DC=xxx,DC=xxxxx,DC=xxx
@Jay based on the code looks like you need to enclose the message in quotes i.e. "...showDialogError(\"" + result1 + "\")", true)
1

There is an opening bracket here with no closing?

"javascript:showDialogError("

Comments

0

I had multiple issues with my code, I had to add beginning and ending quotes in this part of the code (\"" + returnValue + "\")" . Then I had to replace any other double quotes inside of the error message string with single quotes as seen below and replace the single slash (which javascript read as a \u) with double slashes because Javascript was giving me a hexadecimal failure error because of the \u which is now \u.

All of this straightened out allows the asp code to pass an error message to a pretty Javascript box. Hopefully this helps someone else out.

returnValue = returnValue.Replace("\"", "'");
returnValue = returnValue.Replace(@"\", @"\\");
ScriptManager.RegisterStartupScript(Page, this.GetType(), "errorRunExchangeShellMultiCommands", "javascript:showDialogError(\"" + returnValue + "\")", true);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.