locked
jquery not working RRS feed

  • Question

  • User932259438 posted

    If i don't have country I got: please select your country.

    Its ok, but when again I clicked on registration button not responding anymore.

    I tried like that:

    $("#RegistrationForm_lnkRegister").click(function () {
            var prm = Sys.WebForms.PageRequestManager.getInstance();
            alert('TEST');
            performCheck();
    
    
    function performCheck() {
        Page_ClientValidate("ErrormessageValidationGroup");
        if (Page_IsValid) {
            RegisterNow();
            return true;
        }
        else {
          //  alert('No valid');
            return false;
        }
    }

    not working anymore...

    Monday, August 29, 2016 8:52 PM

Answers

  • User281315223 posted

    There are a few things that could be affecting this.

    Ensure your jQuery code is placed within a document-ready block to avoid any issues with your events not being properly wired up :

    <script>
       $(function(){
             // Example 
             $("#RegistrationForm_lnkRegister").click(function () { ... });
       });
    </script>

    You might also consider using the Developer Tools (F12) within your browser and checking to see if any errors are present in the Console. This is usually the best approach to troubleshooting client-side issues.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 29, 2016 9:46 PM
  • User-1142886626 posted

    Hi progy85,

    var prm = Sys.WebForms.PageRequestManager.getInstance();

    Did you used the updatepanel? If you used the updatepanel, please included the JavaScript event in the updatepanel.

    Such as:

    <script type="text/javascript">
            function BindEvent() {
                $(function () {
                    $("#btnSubmit").click(function () {
                        performCheck();
                    })
                })
                function performCheck() {
                    Page_ClientValidate('ErrormessageValidationGroup');
                    if (Page_IsValid) {
                        alert('Do you want to submit data?');
                        return true;
                    }
                    return confirm('Do you want to submit data?');
                }
            }
     </script>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
               <ContentTemplate>
                 <script type="text/javascript">
                     Sys.Application.add_load(BindEvent);
                 </script>
                       ……
                       ……
                   </ContentTemplate>
    </asp:UpdatePanel>
    

    Best Regards,

    Ailleen

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 1, 2016 6:47 AM

All replies

  • User281315223 posted

    There are a few things that could be affecting this.

    Ensure your jQuery code is placed within a document-ready block to avoid any issues with your events not being properly wired up :

    <script>
       $(function(){
             // Example 
             $("#RegistrationForm_lnkRegister").click(function () { ... });
       });
    </script>

    You might also consider using the Developer Tools (F12) within your browser and checking to see if any errors are present in the Console. This is usually the best approach to troubleshooting client-side issues.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 29, 2016 9:46 PM
  • User-1142886626 posted

    Hi progy85,

    Firstly, make sure you have jQuery file referenced correctly, you could take a look with a web developer tool (press F12 in IE8 or above for example). Then check if the jQuery file’s indeed downloaded or not.

    Following link is about how to use it.

    https://msdn.microsoft.com/en-us/library/gg589512(v=vs.85).aspx

    Secondly, it seems you used Page_ClientValidate (), you can refer the ASP.NET Validation in Depth . Maybe you are missing about validation settings on your validator or some other error on js.

    Finally, you could refer the example code:  

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>   
    <script type="text/javascript"> $(function () { $("#btnSubmit").click(function () { return Validate(); }) }) function Validate() { if (Page_ClientValidate('ValidationGroupName')) { return confirm('Do you want to submit data?'); } return false; } </script> <body> <form id="form1" runat="server"> <div> <asp:DropDownList ID="DropDownList1" runat="server"> <asp:ListItem Value="0">Select a Value</asp:ListItem> <asp:ListItem>1</asp:ListItem> <asp:ListItem>2</asp:ListItem> <asp:ListItem>3</asp:ListItem> <asp:ListItem>4</asp:ListItem> </asp:DropDownList> <asp:RequiredFieldValidator ID="rfv1" runat="server" ControlToValidate="DropDownList1" InitialValue="0" ErrorMessage="Please select something" /> <br /> <br /> <asp:Button ID="btnSubmit" runat="server" Text="Submit" /> </div> </form> </body>

    Best regards,

    Ailleen

    Tuesday, August 30, 2016 8:32 AM
  • User932259438 posted

    First I have like that this is working:

    <a id="RegistrationForm_lnkRegister" class="yellow-button" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$RegistrationForm$lnkRegister&quot;, &quot;&quot;, true, &quot;ErrormessageValidationGroup&quot;, &quot;&quot;, false, true))">Join Now</a>

    but after postback I got:

    <a id="RegistrationForm_lnkRegister" class="yellow-button" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$RegistrationForm$lnkRegister", "", true, "ErrormessageValidationGroup", "", false, true))">Join Now</a>
    and not responding anymore...
    Tuesday, August 30, 2016 9:20 AM
  • User-1142886626 posted

    Hi progy85,

    var prm = Sys.WebForms.PageRequestManager.getInstance();

    Did you used the updatepanel? If you used the updatepanel, please included the JavaScript event in the updatepanel.

    Such as:

    <script type="text/javascript">
            function BindEvent() {
                $(function () {
                    $("#btnSubmit").click(function () {
                        performCheck();
                    })
                })
                function performCheck() {
                    Page_ClientValidate('ErrormessageValidationGroup');
                    if (Page_IsValid) {
                        alert('Do you want to submit data?');
                        return true;
                    }
                    return confirm('Do you want to submit data?');
                }
            }
     </script>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
               <ContentTemplate>
                 <script type="text/javascript">
                     Sys.Application.add_load(BindEvent);
                 </script>
                       ……
                       ……
                   </ContentTemplate>
    </asp:UpdatePanel>
    

    Best Regards,

    Ailleen

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 1, 2016 6:47 AM