Bootbox.alert is showing unexpected behavior when called from the back-end of the

While trying to import data from an Excel file to a database using a Bootstrap file uploader, I encountered an issue when trying to display a success message to the user. The initial code I used was:

string strScript = "bootbox.alert('" + Resources.Resource.Success_SaveUserInfo + "');";
Page.ClientScript.RegisterStartupScript(this.GetType(), "UserSave", strScript, true);

Unfortunately, this code did not work as expected. Instead of displaying the alert, the page froze. However, when I switched to the following code snippet, it worked fine:

string strScript = "alert('" + Resources.Resource.Success_SaveUserInfo + "');";
Page.ClientScript.RegisterStartupScript(this.GetType(), "UserSave", strScript, true);

I want to mention that I have already included bootbox.min.js, so that does not seem to be the cause of the issue.

Answer №1

If you want to display a success message in your web application, there are a couple of ways to achieve it.

string strScript = "<script type = 'text/javascript'>bootbox.alert('" + Resources.Resource.Success_SaveUserInfo + "');</script>";
Page.ClientScript.RegisterStartupScript(this.GetType(), "UserSave", strScript, true);

Alternatively,

You can also call a JavaScript function for better reusability:

Page.ClientScript.RegisterStartupScript(this.GetType(), "UserSave", CustomalertFunction('" + Resources.Resource.Success_SaveUserInfo + "'), true);

Simply create a JavaScript function like this:

function CustomalertFunction(message)
{
  bootbox.alert(message);
}

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

AngularJS - ng-repeat: Warning: Repeated items found in the repeater and are not allowed. Repeater:

I'm currently using ng-repeat to showcase a collection of items fetched from the Twitter API. However, I am encountering an issue where Angular attempts to display the empty list while the request is still being processed, resulting in the following e ...

Trouble with sending Json data to server leads to problems with deserialization

My service (service 1) receives a list of key-value pairs, which are then converted to Json and posted to another service (service 2) for processing. Service 1 does not have prior knowledge of the values associated with each key. For example, Service 1 rec ...

Controlling a .Net Application Remotely: Safeguarded Network Management

I have a cross-platform application with all the business logic written in c# .net. I am looking to implement a "Remote Control" feature that allows one app to control another over the network. My priority is ensuring security throughout this process, espe ...

Connect the input field to the grid component

How can I sync the value of the SearchFilter with the FilterGrid to effectively filter the data (refer to code below)? I'm facing an issue where the field clears out the value as I type. There seems to be a problem in how I'm utilizing the state ...

Looking for a way to easily swipe through videos?

My mobile phone viewport displays a series of pictures and videos, with the swipeleft/right function enabled for browsing. However, I noticed that while the swipe feature works fine for images, it stops functioning when a video is displayed. Can anyone p ...

Having difficulty retrieving a response from an API using JavaScript

I have been trying to capture the response using the code below, but unfortunately, I am not able to retrieve it. Can someone please help me and let me know what I might be missing here? function getData() { var request = new XMLHttpRequest(); r ...

An error occurs when trying to access data from the cities of a specific state. The error message reads: "Unable to retrieve property 'data

An error occured: Cannot read property 'data' of undefined at Object.city The issue I am facing is that I am dynamically calling the state parameter. When I use cities.UP.data, it displays the correct result. However, when I try to add cities.st ...

The scroll event is triggered only when scrolling upwards

I am encountering an issue with my scroll function. Currently, it only alerts when scrolling to the top instead of the bottom. How can I correct this so that it triggers the alert when reaching the bottom of the page? $(window).scroll(function() { if ...

What are some strategies for transferring data using ajax?

I am trying to pass o_id as data, but I keep getting an error message: ReferenceError: invalid assignment left-hand side <script src="http://code.jquery.com/jquery-1.10.2.js"></script> <script type="text/javascript"> $("#ass ...

Svelte's feature prevents users from inputting on Mapbox

My goal is to prevent user input when the variable cssDisableUserInput is set to true. Here's what I have within my main tags: <div id=userinput disabled={cssDisableUserInput}> <div id="map"> </div> Within my CSS, I&a ...

JavaScript does not function properly with dynamically loaded content

Trying to load the page content using the JQuery load() method. See below for the code snippet: $(window).ready(function() { $('#content').load('views/login.html'); }); .mdl-layout { align-items: center; justify-content: center ...

Issue with Google Charts where the label does not show outside of the bar if the bar is too small

I am encountering an issue with my Google Bar Chart where the bar label is not displaying outside of the bar when it is too large to fit inside. This behavior should be the default, but my charts are not working as expected. The problem can be seen in rows ...

React-xarrows is a stunning display of multiple arrows overlapping each other in a mesmerizing fashion

I am currently using the react-xarrows library within my project to connect tables in a diagram. However, I have encountered an issue where multiple links between two tables cause the arrows to overlap, resulting in only one visible link instead of the int ...

Which slider was featured in the unity3d.com/5 website?

While browsing the internet, I came across the website and was intrigued by the slider effect featured in the "graphics" section. I am eager to figure out how to replicate that stunning visual effect. ...

How to implement an instance method within a Typescript class for a Node.js application

I am encountering an issue with a callback function in my Typescript project. The problem arises when I try to implement the same functionality in a Node project using Typescript. It seems that when referencing 'this' in Node, it no longer points ...

What is the best location to specify Access-Control-Allow-Origin or Origin in JavaScript?

After researching, I found out that I need to set my Access-Control-Allow-Origin or Origin tags. But the question is: where do I actually add these? The suggestions were to use them in the header section. I couldn't find any detailed explanation on t ...

Even with CORS enabled, the dreaded cross-origin error persists

I've been attempting to access a node route in Angular using the $http method and the cors module. I've tried implementing a basic app.use(cors()); but the error persists. I also followed guidelines from the cors documentation by creating a whi ...

Generating a distinct identification for a row using JavaScript

Here is my JavaScript function for dynamically adding new rows to a table in HTML. I want each row to have a unique ID. This is the code I have so far: $(document).ready(function(){ var html = '<tr><td class="cb"><inpu ...

Sort columns using drag and drop feature in jQuery and AngularJS

Utilizing the drag and drop feature of jquery dragtable.js is causing compatibility issues with AngularJs, hindering table sorting functionality. The goal is to enable column sorting by clicking on the th label and allow for column rearrangement. Currentl ...

Upgrading email functionality: Combining PHP mail() with AJAX

My issue revolves around using the mail() function. When AJAX code is present, the email gets sent but without any message (the subject is intact though). However, when I remove the AJAX code, the email goes through without any problems. I'm not well ...