The font size escalates following the activation of a Java alert box on an ASPX webpage

Recently, I came across an interesting solution to a problem with a PHP application. It was discovered that placing the Java Script in the body section resolved the issue where CSS file attributes were being ignored when clicking the Alert box. In my code behind on the aspx.vb page load, I have a script for an Alert box that either appears or remains invisible based on the query parameter sent to the page - [?id=1] or [?id=2]. When the link directs the user to the page with the alert box, it sends [?id=1]. An if statement in the code behind is responsible for hiding the box if it is [?id=1]. After the user enters data and clicks a button to proceed to an emailing page, they are then redirected back to the original page with the alert box and [?id=2] is sent. The If statement reads the [?id=2] and displays a message confirming that the email went through. Clicking the alert [Okay] button triggers an increase in font size. Currently, both the If statement and JavaScript are placed within the Page Load function in the code behind. My question now is: where should I place the If statement (if at all) so that the css file attributes are not ignored upon reload?

Below is the example of the If statement within the page load function. How can I integrate this into the ASPX page or is there another approach I should consider?

    If Request.QueryString("id") = "2" Then
        Response.Write("<script language=""javascript"">alert('Your Early Order information has been sent to the Purchasing Department');</script>")
    Else
        'Do nothing
    End If

Answer №1

To enhance your code, consider replacing instances of Response.Write with

ClientScriptManager.RegisterStartupScript
.

If you'd like to delve into the reasons and distinctions between them, check out this informative StackOverflow discussion.

An updated snippet showcasing this change:

If Request.QueryString("id") = "2" Then
   ClientScript.RegisterStartupScript(Me.GetType(), "AlertScript", "alert('Your Early Order information has been sent to the Purchasing Department');", True)
 Else
     'Do nothing
 End If

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

Identify modifications to properties in Angular

What is the most effective method for responding to property changes within a component? I am seeking a solution that will trigger a specific function every time a property in a component is altered. Consider the following example with a single component: ...

Placing images of varying sizes and aspect ratios within a div container and ensuring they fill the space

My website allows users to upload images, and the server processes them to a size of 400px*400px. The original sizes of the images vary, making it challenging to display them properly within a 200px*200px div. I'm looking for a way to crop the images ...

What is the best way to connect to the Microsoft Azure Machine Learning Studio API - through Vue Axios or an Express

I am currently utilizing the following code to establish a connection with a web service. However, I now require assistance in connecting to the Microsoft Azure Machine Learning Studio Api using Vue Axios or Express. Can someone provide guidance? var http ...

Issues arise when utilizing the fill() function on a canvas due to its inconsistent and unpredictable behavior

I've been working on learning how to draw and fill different shapes using canvas and JavaScript. However, I've been having trouble getting my shapes to fill correctly. In my HTML document, all I have is a simple line: <canvas id="canvas1& ...

How to dynamically assign a name attribute to tags in a string using React and JavaScript

Streamlining the current blog post. If I have a string let someText = "<h1>test</h1><p>desc of test</p>" I want to use React or JavaScript to transform it into someText = "<h1 id="test">test</h1><p>desc of test ...

EJS variable not detected by Visual Studio IDE in JavaScript file

Working on a Node.js project with the express framework and utilizing EJS as the template engine, my IDE of choice is Visual Studio. Encountering an issue when using EJS variables within the same ejs file. Though it renders correctly and functions perfect ...

What is the proper way to install Vuetify when the webpack.config.js file is missing?

The Vuetify documentation mentions the following: After installation, you need to locate your webpack.config.js file and insert the provided code snippet into the rules array. If you already have a sass rule configured, you may need to make some adjustme ...

What could be the reason for a variable not being assigned a value following the xmlhttp.responseText?

During the validation process of a send-fax form, I am checking if a fax has been previously sent using our software fax package. This involves a simple query to a table executed by a script, which will return text if a previous fax exists or blank if not. ...

How to style multiple tags using CSS

Is there a way to style specific tags in CSS? <style type="text/css"> [attribute*="test"] { background-color: red; } </style> However, this method does not seem to work for the following tags: <test-1> </test-1> <t ...

Error encountered while executing a join query in Node.js

My stack includes express.js, sequelize, and mysql Database Structure A : { id: 1, name: ... } B : { A_id: 1, name: name1 }, { A_id: 1, name: name2 } A Model (models/A.js) A.association = models => { A.hasMany(models.B, { foreignKey: 'A_id&ap ...

Ways to present a pop-up dialog box featuring word corrections

I have developed a word correction extension that encloses the incorrect word in a span element. Upon hovering over the word, a drop-down menu with possible corrections should be displayed. However, my current code is not functioning properly. How can I en ...

Creating a dynamic menu structure by tailoring it to the specific elements found on each page

Currently, I am facing issues while attempting to generate a dynamic menu based on the elements present on the page. Is there a way to develop a menu using the following code structure?: <div class="parent"> <div class="one child" id="first"& ...

Utilizing Vue.js transitions to display content with a one-time transition limit

I have followed the Vue.js documentation given below to implement the show transition, but I'm struggling with stopping the hide effect on the second click. Is there a way to achieve this? https://v2.vuejs.org/v2/guide/transitions.html#a Can I conti ...

Can anyone assist with troubleshooting the font size issue for a JavaScript tooltip on Joomla 1.5 with CK Forms?

My Joomla 1.5 site has CK Forms installed and is functioning properly, except for one issue: the tooltip on the captcha is not displaying correctly. It appears in a tiny 1px font size. Even though I have tried debugging using Firebug and confirmed that the ...

Implementing a callback function following the completion of file reading in Phonegap

I have been facing this issue for quite some time now and I need assistance in finding a solution: When it comes to developing an android app, I rely on the phonegap framework. There is an async function called readFromFile() that reads a json file store ...

Stopping the papaparse streaming process once a certain number of results have been achieved

Currently, I am utilizing the PapaParse library to parse a large CSV file in chunk mode. During my data validation process, I encountered an issue where I was unable to stop streaming the data once validation failed. I attempted to halt the streaming by ...

Employing a function to concatenate promises

In my coding process, I have come across a situation where I need to fetch content and then save it using two separate functions. Each function performs a different task based on the type of content provided. These functions act as helper functions in my o ...

Retrieving JSON information from asynchronous JavaScript and XML (AJAX)

I am struggling with making a URL that contains JSON Data work properly. The issue lies in the data field - I am unsure of what to input here as it is currently undefined. My goal is to store an array of the JSON data received from the ajax request. What ...

How to vertically align a div inside another div

My Goal: Ensuring that the divs with "col-md-1" (the vote total and vote arrows) are vertically aligned in the center of the parent div HTML Structure: <div class="row container-fluid"> <div class="col-md-1 centered-div"> <p id ...

Is it possible to selectively mock certain components of an external module using jest?

I am totally new to using Jest, especially in regards to unit tests, and I am struggling to write a test for a specific scenario. I know that you can mock an external module like this.. jest.mock('@organisation/library', () => ({ Database: j ...