简体   繁体   中英

Font size increases after a Java alert box is clicked on and ASPX page

I saw a great answer to this question on a PHP application. The fix for this was to put the Java Script in the body section because the css file attributes are ignored when clicking the Alert box. I have script for an Alert box in my code behind at aspx.vb page load that appears or remains invisible depending on what I send the page [?id=1] or [?id=2]. The link that gets to the page with the alert box on it sends [?id=1]. An if statement in code behind hides the box if it is [?id=1]. Once a person completes entering data on the page, he/she clicks a button that sends the user to an emailing page, which then redirects the user back to the page with the alert box and sends [?id=2]. The If statement page reads the [?id=2] and the box appears stating that their email went through. Click the alert [Okay] button and the fonts increase their size. Right now the If statement and Java script are in Page Load on the code behind. Where do I put the if statement (and how) so reload does not ignore the css file attributes.

Here is the If statement placed in page load. How do I put them on the ASPX page or do I?

    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

You should replace your Response.Write with ClientScriptManager.RegisterStartupScript .

You can read the reason and differences in this StackOverflow post .

Your updated code would look like this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM