locked
JavaScript code not working on any browser when I run the program from MS Visual Studio 2015 RRS feed

  • Question

  • User121433041 posted

    After I  installed MS Visual Studio 2015 for Web & MS Community, existing JavaScript code from my Web Application stopped working

    Saturday, November 5, 2016 4:10 AM

All replies

  • User-1838255255 posted

    Hi himak,

    According to your description, I make a test in my side then it  run perfect, my test environment is  Microsoft Visual Studio Community 2015 version 14.0.25420.01 Update 3.

    1. I suggest you can use break point in browser , like this:

    2.Also you can write alert("***")  at the begin of JavaScript code, check the browser if execute the js code.

    3. If this can't solve your problem, please post you javasecript code.

    Best Regards,

    Eric Du

    Saturday, November 5, 2016 7:56 AM
  • User2053451246 posted

    Try making a new solution with one of the templates and adding something simple to it to see if it works.  All of your different posts you've complained about this happening but have never posted any code that you've wrote, and installing any version of Visual Studio won't make any web browser stop running JavaScript.

    You say "Web Application", but what kind?  Web Forms or MVC?  When attempting to run your "Web Application" what does the debugging console of the web browser say for network or other errors?

    Saturday, November 5, 2016 9:39 AM
  • User121433041 posted

    Finally I found out that,below code is going to newform.aspx page even though validateName() returns false. In my IDE, insert breakpoints are not working for me. When I click on 'Start Debugging', it's just running the program but not debugging. Can you please guide me? I am a learner.

    <% @Page Language="C#" %>
    <% @Import Namespace="System.IO" %>

    <html>
    <head runat="server">
    <script type="text/javascript">
     function formvalidate() {
        
            var fname = document.getElementById("firstName").value;
            var lname = document.getElementById('lastName').value;
            var emailjs = document.getElementById('email').value;
            if (validateName(fname, "First Name")) {

            }
        }
     
         
        function validateName(element, value) {
            if (element == "") {
                alert("Please enter your " + value);
                return false;
            }
            else
                return true;
        }

    </script>
    </head>


    <body>
      <form id="form1" style="font-family:verdana;font-size:14px;" runat="server" method="post" action="newform.aspx">

    <div style="text-align: center;">
    <h2>Please Enter Your Information Below</h2>
     <asp:table runat="server" align="center" CellSpacing="20">
         <asp:TableRow ID="fname" runat="server">
            <asp:TableCell>First Name : </asp:TableCell>
            <asp:TableCell> <asp:TextBox ID="firstName" runat="server" style="width:224px" /> </asp:TableCell>
        </asp:TableRow>
     
        <asp:TableRow ID="lName" runat="server">
            <asp:TableCell>Last Name : </asp:TableCell>
            <asp:TableCell> <asp:TextBox ID="lastName" runat="server" style="width:224px" /> </asp:TableCell>
        </asp:TableRow>
     
        <asp:TableRow ID="emailRow" runat="server">
            <asp:TableCell>Email Address:  </asp:TableCell>
            <asp:TableCell><asp:TextBox ID="email" runat="server" style="width:224px" /></asp:TableCell>
        </asp:TableRow>

        <asp:TableRow ID="phoneNumber" runat="server">
            <asp:TableCell>Home Phone# :  </asp:TableCell>
            <asp:TableCell><asp:TextBox ID="phoneNo" runat="server" style="width:90px" MaxLength="12"></asp:TextBox> </asp:TableCell>
        </asp:TableRow>

     </asp:table>

     <asp:Button ID="adopt" runat="server" Text="Submit" font-size="X-Large" Font-Bold="true" OnClientClick="return(formvalidate());" />            
     
     </form>
    </body>
    </html>



    Saturday, November 5, 2016 4:09 PM
  • User121433041 posted

    OnClientClick event was working earlier. When I reinstalled VS, it stopped working. Could someone suggest what was the reason? And also the alternative event which I can use instead.

    Sunday, November 6, 2016 9:22 PM
  • User-1838255255 posted

    Hi himak,

    I test your code, I found it run perfect. Here is the result, it can trigger client event:

    So my suggestion is suggest debug your javascript code, here are two debug methods,

    1. you can run your code in Browser(IE), then press F12, insert breakpoint in the code, then refresh page and press F11 step by step debug.

    2. you can add a debugger in the JavaScript code, in this way, when you debug code in F12, it will stop at debugger's place!

    Best Regards,

    Eric Du

      

    Tuesday, November 8, 2016 8:55 AM