Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript Message Box - ASP.net

    Hi,

    I have an asp.net form...

    I also have a js message box which fires when a user makes a certain selection

    When this message box fires the webpage automatically goes to the top of the page

    If the user is towards the end of the form and the js box fires - this brings them right back to the top of the page...

    Here's my code - is there a way to stop the webpage from bringing the user back to the top when the message box fires?

    Hope that makes sense, here's my code...

    Thanks

    Dim message As String = "You have the wrong form"
    Dim sb As New System.Text.StringBuilder()
    sb.Append("<script type = 'text/javascript'>")
    sb.Append("window.onload=function(){")
    sb.Append("alert('")
    sb.Append(message)
    sb.Append("')};")
    sb.Append("</script>")
    ClientScript.RegisterClientScriptBlock(Me.GetType(), "alert", sb.ToString())

  • #2
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    I don't understand anything .NET, but looking at just the JavaScript it looks as if an alert dialog is popping up on every page load. If the form is scrolling to the top, are the fields blank, or do they still have values in them? If they are blank, then the form is submitting.
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •