SyntaxError: An unexpected illegal token was found in the ASP.NET code

In my ASP.NET project, I'm attempting to trigger a popup on button click.

void Btn_Click(Object sender,EventArgs e)
{
 string message = "**System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Exception: ::<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4c7d0c7d7c7c62787862797b627b7e">[email protected]</a> you are not authorized at EndPoint.Common.AuthenticateExt`(String uniqueKeyForLog, QueryLimitControlFor product) in d:\Builds\PROD\EndPoint\PROD - 5 EndPoint\src\EndPoint\Common.asmx.cs:line 141 at EndPoint.Common(ExtendConfirmParameters ConfirmParameters) in d:\Builds\PROD\EndPoint\PROD - 5 EndPoint\src\EndPoint\Common.asmx.cs:line 96 --- End of inner exception stack trace ---**"


dialog(this.Page, "Error", message , 400);

}



public void dialog(Page page, string title, string message, int width)
{

ScriptManager.RegisterStartupScript(page, this.GetType(), "dialog", "$('body').append($('<div>').attr({id:'dialog',title:'" + title + "'}));$('#dialog').html(' <style>  .no-close .ui-dialog-titlebar-close {  display: none;}</style><p>" + message + "</p>');$('#dialog').dialog({autoOpen: false,width: " + width.ToString() + ",modal: true,dialogClass: 'no-close',buttons: [{text: 'Okay',click: function() {$( this ).dialog( 'close' );$('#dialog').remove()}}]});$('#dialog').dialog('open');", true);

}

Query:

If I attempt to show the following message in a dialog box

**System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Exception: ::<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="97a6d7a6a7a7b9a3a3b9a2a0b9a0a5">[email protected]</a> you are not authorized at EndPoint.Common.AuthenticateExt`(String uniqueKeyForLog, QueryLimitControlFor product) in d:\Builds\PROD\EndPoint\PROD - 5 EndPoint\src\EndPoint\Common.asmx.cs:line 141 at EndPoint.Common(ExtendConfirmParameters ConfirmParameters) in d:\Builds\PROD\EndPoint\PROD - 5 EndPoint\src\EndPoint\Common.asmx.cs:line 96 --- End of inner exception stack trace ---**

I encounter the following error :

Uncaught SyntaxError: Unexpected token ILLEGAL 

Which specific character is causing this unexpected behavior in the above message?

How can I address this issue in my ASP.NET application?

Any assistance would be highly valued.

Thank you.

Answer №1

Your code contains invalid escape sequences that need to be corrected:

d:\Builds\PROD\EndPoint\PROD 

To fix this, add an ampersand (@) at the front of your string like this:

string message = @"**System.Web.Services.Pro....

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How do you toggle the visibility of a dependent <select> in an HTML form?

In my HTML jQuery form, I need to display a second select box based on the user's selection in the first select box. Should I use .show() to reveal a previously hidden div or should I use .append() to populate an empty select element? In other words, ...

Troubleshooting ASP.NET code behind issue with setting button command

Creating a button in C# with command: Button infoBtn = new Button(); infoBtn.Command += InfoButton_Command; infoBtn.CommandName = "handleinfoclick"; infoBtn.CommandArgument = id; Attempting to implement the command handler: private void InfoButton_Comma ...

What is the most efficient and hygienic method for storing text content in JavaScript/DOM?

Typically, I encounter version 1 in most cases. However, some of the open source projects I am involved with utilize version 2, and I have also utilized version 3 previously. Does anyone have a more sophisticated solution that is possibly more scalable? V ...

Displaying the fields of the selected [object Object] in the console.log

Currently, I am utilizing "express": "3.2.6",, nodeJS v0.10.25, and "express-myconnection": "1.0.4",. The database connection appears to be functioning properly. However, when attempting to query in my view: console.log("Data: " + rows); The output rece ...

Error: Unable to locate package @babel/preset-vue version 7.1.0

I am currently working on a simple website using Ruby on Rails and Vue.js, but I am running into issues when trying to start the local server. After executing npm run dev in the terminal, I encountered 2 errors: This dependency was not found: * /Users/mu ...

Vue warning: Do not modify the prop "taskToEdit" directly

I am facing an issue with my props editToTask : app.js:42491 [Vue warn]: To prevent overwriting the value when the parent component re-renders, avoid directly mutating a prop. Instead, use a data or computed property based on the prop's value. Mutate ...

endless cycle of scrolling for div tags

My goal is to incorporate a tweet scroller on I believe it uses the tweet-scroller from Unfortunately, this link seems broken as the demo is not functioning. I searched for an alternative solution and came across http://jsfiddle.net/doktormolle/4c5tt/ ...

Error: No @Directive annotation was found on the ChartComponent for Highcharts in Angular 2

I'm having trouble integrating Highcharts for Angular 2 into my project. After adding the CHART_DIRECTIVES to the directives array in @Component, I encountered the following error in my browser console: EXCEPTION: Error: Uncaught (in promise): No ...

Graphing a Spline Graph with fixed values at the diagonal points of 0,0 while keeping the rest of the plot unchanged

Our game is utilizing a Spline Graph, but we are encountering an issue with setting the x and y axis values to 0,0 and saving these values from the beginning until the end for plotting purposes. View Live Demo Here https://i.sstatic.net/jjZ1U.png JavaSc ...

Issue with template updating when utilizing ui-router and ion-tabs in Ionic framework

CODE http://codepen.io/hawkphil/pen/LEBNVB I have set up two pages (link1 and link2) accessible from a side menu. Each page contains 2 tabs: link1: tab 1.1 and tab 1.2 link2: tab 2.1 and tab 2.2 To organize the tabs, I am utilizing ion-tabs for each p ...

Sencha Touch's actionable column

Does Sencha Touch have an xtype: actioncolumn similar to ExtJS 4.1 for column configuration? If not, what alternatives does Sencha Touch offer? ...

Sending property via div

In my ReactJS project, I am working on creating a dynamic div board. To properly position the elements on the board, I need to pass props such as row and column IDs. componentDidMount() { let board = []; for(let i = 0; i < 30; i++){ for(let j = ...

Error occurred while attempting to execute the method

Here's a MongoDB Mongoose query we're dealing with: sampleSchema.find({ $where: "expired <= " + (new Date()) }) .limit(9) // Problems may arise from here .sort({ postedDate: -1 }) .then((docs) => { console.log(&apos ...

The functionality of Nuxt's asyncData is restricted when attempting to access data from authorized express routes

Setting up an online store. I began with the products, which can be pulled without authorization but require it for editing. The process is smooth so far, probably because it's happening on the client side where authentication information is included ...

Node.js: Configuring keep-alive settings in Express.js

How can I properly implement "keep alive" in an express.js web server? I came across a few examples.. Example 1: var express = require('express'); var app = express(); var server = app.listen(5001); server.on('connection', function(s ...

Gain entry to Zurb Foundation for Apps modules within your AngularJS application

Currently, I am developing an AngularJS application utilizing Foundation for Apps. One key element in my layout is a Foundation Apps panel that serves as the top menu. <div zf-panel="" id="topMenu" position="top" class="panel-fixed">...</div> ...

How to extract a particular value from a JSON object using AJAX?

In my test.php file, I have implemented a code where ajax sends a request from index.php to this page. Within this page, I have created an array, converted it to JSON, and returned it as follows: <?php $arr = array( "status"=>200, "result"=>array ...

When the "visible" property of a control is set to "False," will any of its events still trigger?

In my scenario, I have a GridView with the RowDataBound event set up. My question is, if I change the GridView's "Visible" property to "False" during a postback triggered by another control's event (such as a button's OnClick event), will th ...

Image swaps with timer for button

I am working on a project where I have a page with 5 image buttons arranged horizontally. The objective is to have the images on each button change sequentially every 3 seconds in a continuous loop. Here is my code: $(document).ready(function (){ Beg ...

How to assign the 'src' attribute to an HTML element using Node.js

I am currently using 'express' in Node.js and have implemented the following code to send a URL input into text: <form method="GET" action='/download' class="my-5"> <div class="form-group"> ...