Executing an alert() function on the server-side using Javascript

Is there a way to trigger a JavaScript alert popup from a VB.net function, other than using RegisterStartupScript? I've only been able to make it work within Page_Load or Page_Prerender so far.

Edit: I have provided more details about my specific situation below.

Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSubmit.Click

    blnEditComplete = RunEditChecks()

End Sub


Function RunEditChecks() as Boolean

    'edit checks 
    ...
    ...
    ...

    ScriptManager.RegisterStartupScript(Me.Page, Me.GetType, "warning", "alert('WARNING: Price must equal Contract Price.');", True)

    ...
    ...
    Return True

End Function

Answer №1

Function in JavaScript:

function showAlert(){
    alert('Please verify that the price matches the contract price.');
}

In vb.net:

ScriptManager.RegisterStartupScript(Me, Page.GetType, "Script", "showAlert();", True)

Similar question: link

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

Why isn't pagination typically positioned inside of a tbody element rather than before or after it?

I've created a user table that is based on the number parameter. I added a filter that listens to input and performs an AJAX call each time with the filter applied to the name field. However, the pagination is initially displayed ABOVE the entire ta ...

What is causing this form to submit?

I need help with sending emails via AJAX. My problem is that the form keeps submitting and refreshing, even though I haven't used GET to send anything in the URL. HTML: <form onsubmit="ajaxEmail(); return false;" > <input type=" ...

Is it necessary to create a Node endpoint for each item in the array?

My current tech stack includes ExpressJs, NodeJs, and AngularJs. Imagine I have an array containing various objects representing grocery store accounts and the amounts owed to them by the bank. [{ account: 1, amount: 2.33 }, { account: 2, amount: 5.99 ...

Display a custom AngularJS directive on content loaded through $http request

I'm facing a dilemma. I have created a directive app.directive('a', function() { return { restrict: 'E', link: function(scope, elem, attrs) { elem.on('click', function(e){ ...

Tips for extracting values from a Multiple Search Selection dropdown box using react-semantic-ui

I am having trouble retrieving the selected values from a Multiple Search Selection dropdown using the semantic-ui-React component. Although I have successfully rendered the items and enabled searching and selecting, I am struggling to extract the chosen v ...

Confirming the validity of JSON data in multiple dimensions

Does this text require any modifications or improvements? I'm dealing with a set of data that closely resembles the actual information and I want to make sure that my JSON file is correctly structured with nested objects and arrays. let data = ...

There seems to be an issue with saving posts to the database when using RESTful services

Problem with POST request not saving data properly in database I am using Node.js with Express and Mongoose for RESTful services. Here is my model: var mongoose = require('mongoose'), Schema = mongoose.Schema; var bookModel = new Schema({ title ...

Generate a customizable button in Bootstrap using JavaScript extensions

After some investigation on Bugzilla, I discovered that by setting the options URL in install.rdf to arbitrary JavaScript, it can run smoothly. However, a strange issue arises where the window deactivates, as if an invisible dialog has appeared over it, ma ...

Using three.js to manipulate the camera's movement on the geometry generated in Autodesk Viewer from Point A to Point B

I am currently working on transitioning my camera view state from Point A to Point B within the Autodesk viewer. To achieve this, I am creating a path using LineDashedMaterial and have successfully displayed the line connecting Point A and B. Below is the ...

Comparing jQuery and Yahoo UI API Design

I find myself puzzled by the contrasting design approaches of jQuery and Yahoo UI APIs. I must confess, I have a strong aversion to the jQuery API, but my knowledge in web programming and JavaScript is limited, so I could be completely mistaken and end up ...

Is JavaScript Promise Chaining Allowed?

I have a question regarding my code, despite it currently functioning correctly. Specifically, I'm wondering if the sequence of promises in my database is valid. Promise 1 must be fulfilled before moving on to Promise 2 because I rely on the data and ...

Capture an image from the webcam without any manual intervention and store it in the system's directories

Looking to automate the process of capturing a picture from a webcam once access is granted, and then saving it without any user intervention. I've managed to capture the image but struggling with: A) Automating the capture process B) Saving the ca ...

What is the most effective way to convert an array into an object using index signatures and classes as types?

I am facing a challenge involving transforming an array of type A into an array of type B and then passing it to a class called Person as input data. I am currently stuck and uncertain about how to accomplish this task. Here is the definition of Type A an ...

HAproxy: unique error handling for OPTIONS and POST requests with 503 errorfile

Our Web application utilizes ajax calls to a backend that operates on a different domain, requiring CORS. The backend setup includes an HAproxy 1.4.22 along with multiple Wildflys running on the OpenShift PaaS. During times when a Wildfly instance is unava ...

Integrating component names into a tag in React

I've encountered a similar issue before, but unfortunately, the suggested solutions aren't working for me. I suspect it might have something to do with how I am conditionally rendering components. Essentially, I have a selection of choices for th ...

Issue with displaying the scrollbar in Tailwindcss

<div className="col-span-3 h-screen overflow-y-scroll "> <ul className="m-5"> <li className="flex items-center mb-4"> <FontAwesomeIcon icon={faRss} classNa ...

"Authorization refused" notification on Internet Explorer 6

Encountering an error in IE6 on line 10 with this code. Specifically, var ref = ...; What could be causing the issue here? <html> <head> <title>JavaScript Popup Example 3</title> </head> <SCRIPT language="JavaScript1.2"& ...

Is there a more efficient alternative to the sluggish scroll event?

Currently, I have set up a scroll event that tracks the user's position on the page and updates the navigation styling based on which section they are viewing. However, the calculation I'm using during scrolling is quite resource-intensive and ca ...

Discover the best way to sort products by category

I'm in the process of developing an online store where customers can choose from three options: "body lotion," "body wash," and "body scrub." Once a selection is made, the corresponding product will be displayed. The products are stored in an array n ...

AngularStrap's bs-modal is failing to display content

I have a question, here is a Plunker with the code: http://plnkr.co/edit/SNFy2XcOBefUavG1QCqD?p=preview <button class="btn btn-default" data-template="customer.tpl.html" bs-modal="modal">New Customer </button> < ...