As well as the missing single quote, your message needs to be properly encoded. You are currently outputting:
alert('Request saved successfully and send to Maker for verification(Test -
Invalid OIC Type for Loans!); window.location.href = 'Test_Initiation.aspx?...';
which won't work, because normal JavaScript strings can't contain unescaped line-breaks.
You should be outputting:
alert('Request saved successfully and send to Maker for verification(Test - \r\nInvalid OIC Type for Loans!'); window.location.href = 'Test_Initiation.aspx?...';
Use
HttpUtility.JavaScriptStringEncode
to encode your message before appending it. You should probably encode the
queryString
as well, just to be safe.
ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "alert('Request saved successfully and send to Maker for verification" + "(Test - " + HttpUtility.JavaScriptStringEncode(strTest) + "'); window.location.href = 'Test_Initiation.aspx" + HttpUtility.JavaScriptStringEncode(queryString) + "'; ", true);
I think it would probably be cleaner to use
string.Format
, to build the script:
ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", string.Format("alert('Request saved successfully and send to Maker for verification(Test - {0}'); window.location.href = 'Test_Initiation.aspx{1}';", HttpUtility.JavaScriptStringEncode(strTest), HttpUtility.JavaScriptStringEncode(queryString)), true);
That should make it easier to spot any syntax errors in your script.
HttpUtility.JavaScriptStringEncode Method (System.Web) | Microsoft Docs[
^]