Error encountered when attempting to display an alert using ClientScript.RegisterStartupScript within an UpdatePanel

Currently, I'm in need of displaying a Success Message and upon clicking OK, it should automatically Redirect me to another Page. While everything was working perfectly, the introduction of an UpdatePanel seems to have caused the Alert not to show up.

Here is my code:

ClientScript.RegisterStartupScript(typeof(Page), "Create Time Table", "<script language='JavaScript'>alert('Time Table Created Successfully.'); window.location.href = 'create.aspx';</script>");

I have also attempted the following variations:

ClientScript.RegisterStartupScript(typeof(Page), "Create Time Table", "<script language='JavaScript'>alert('Time Table Created Successfully.'); window.location.href = 'create.aspx';</script>", true);

ClientScript.RegisterStartupScript(typeof(Page), "Create Time Table", "<script language='JavaScript'>alert('Time Table Created Successfully.'); window.location.href = 'create.aspx';</script>", false);

Unfortunately, these solutions did not work as expected.

Answer №1

For those using an update panel, provide the update panel ID and its type as shown below:

ScriptManager.RegisterStartupScript(
                UpdatePanelID,
                UpdatePanelID.GetType(), 
                "Create Time Table", 
                " alert('Time Table Created Successfully.'); window.location.href = 'create.aspx';",
                true);

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

issues with jquery functionality on user control page

For searching through dropdown lists in my project, I have implemented the Chosen jQuery plugin. In the Master page before the closing body tag, ensure to include the necessary CSS and jQuery script files. <link href="/assets/css/chosen.css" rel=" ...

Tips for positioning HTML elements at the exact mouse location as it moves, without any delay?

Currently, I am in the process of developing a web-based drawing application that does not rely on using a canvas. My decision to avoid using a canvas is because I plan to incorporate CSS Keyframes into the HTML elements upon placement. This approach allow ...

I'm seeing a message in the console that says "Form submission canceled because the form is not connected." Any idea why this is happening?

For the life of me, I can't figure out why this code refuses to run the handleSubmit function. Essentially, the form is supposed to take an input and execute the handleSubmit function upon submission. This function then makes a POST request to an API ...

Automatically show a specific accordion section when the page loads

I have different accordion elements like this: <div class="accordion"> <h3 style="width: 430px">Location</h3> </div> <div class="accordion"> <h3 style="width: 430px">Category</h3> </div> Upon ini ...

The transparency in Three.js took a turn for the worse after the update from r67 to r68

I encountered a strange problem when switching from three.js version 67 to version 68. In version 67, everything appeared correctly (triangles behind transparent triangles were visible), but in version 68, something seems to have gone awry. Below are two ...

Is there a way to retrieve data from local storage after every login in Laravel?

Utilizing Laravel 5.3, I have been storing my data on local storage using JavaScript: localStorage.setItem('storedData', JSON.stringify(data)) Now, when a user logs in, I want to implement a condition. If the stored data exists in the local sto ...

concealed highcharts data labels

I attempted to create a bar chart using Highcharts, and initially it worked fine. However, I encountered an issue when displaying multiple indicators - the datalabels for certain data points are hidden. For example, the datalabel for "provinsi aceh" is not ...

The controller function is being executed two times due to the usage of ng-show

I have a basic Angular application set up with the following code: index.html <!DOCTYPE html> <html> <head> <script src='https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js'></script> < ...

Why do we frequently employ C# attributes with the 'Attribute' suffix?

Recently I came across some C# code that utilizes various LINQ to SQL attributes with the Attribute suffix, like ColumnAttribute, rather than the usual Column. I'm curious if there is a specific reason for this aside from making the code more verbose? ...

The then() function in Node.js is triggered before the promise is fully resolved

I'm struggling to get my Promise function working as intended. Here's what I need to accomplish: I am receiving file names from stdout, splitting them into lines, and then copying them. Once the copy operation is complete, I want to initiate oth ...

What method does the .NET runtime use to distinguish between two types?

Assembly A has a static dependency on type T (a reference type, a class) in assembly B. I don't own assembly A but I do have control over assembly B. Unfortunately, T is a concrete type and not an interface. However, A uses reflection to discover the ...

The query datetime picker is unable to retrieve the date when called in a different function

Could you please clarify why I am receiving an "undefined" value in the second alert of the loadchart function call? What is causing the error here? I am encountering an issue with fetching dates from a date timepicker while using Bootstrap. Below is my ...

Utilizing jQuery: How to pass the $this object along with additional parameters to a

Is there a way to pass the value of this along with other parameters to a function? I have attempted the following methods, but they have not been successful: function update_alt($this, my_param){ this_alt = $(this).attr('alt'); ...

"Automate the process of manual content duplication with JavaScript's for each replacement

Seeking a solution to automate the selection process without writing individual JS scripts for every input. For instance, having 10 double inputs (total of 20 inputs) and utilizing the each() function or other methods by only declaring selectors. Find th ...

How should classes and their corresponding files be named in ASP.NET web applications according to best practices?

Could you offer some guidance on how to properly name classes and their files within an ASP.NET assembly? I am aware of the basic rule that a class should start with a capital letter and be a noun. However, I have multiple namespaces and projects in my pro ...

Using the Selenium library in C#, you can easily initiate a new browser window

I am attempting to launch a new window in Firefox using the same webdriver, or any other method. Let's say I am currently on a page with the URL www.abc.com and now I need to open another page, www.xyz.com, where I will need to perform some actions a ...

The pageSource in IE Webdriver fails to refresh after a change on the page caused by JavaScript

Currently, I am working on automating a Web application using Selenium in C#. My task involves clicking on a link on the home page which redirects me to another page. To switch to this new page, I have implemented the following code: string parent = webDri ...

How can I identify the blur or focusout event in a tinyMCE textarea?

I have been tackling with an existing project. Whenever I click on some editable text within the webpage, it transforms into a textarea and shows the tinyMCE toolbar. However, when I click outside of that textarea, the toolbar disappears. I am trying to fi ...

Having trouble with collapsing elements on JavaScript?

I am encountering an issue with the code provided below. It seems to be working fine in this JSFiddle link: http://jsfiddle.net/e6kaV/33/. However, I am receiving the following error message: { "message": "Uncaught ReferenceError: $ is not defined", ...

The issue persists with react-hook-form and Material UI RadioGroup as the selected value remains null

Having trouble with RadioGroup from Material UI when using react-hook-form Controller. I keep getting a null selected value, even though my code seems right. Can you help me figure out what's missing? import * as React from "react"; import { ...