Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a user control with many javascript functions. When I am adding this to my project ,some of the fuctions are working properly but some not.
I am using the below script for keypress event of a textbox


XML
<script type="text/javascript">
                        var to; // variable to which we assign setTimeout function
                        var prm = Sys.WebForms.PageRequestManager.getInstance(); // Page Request Manager object

                        function onTxtKeyUp(e, buttonid) {

                            if (e.KeyCode != 9)
                                to = setTimeout(function () {
                                    performSearch(buttonid);
                                }, 300)
                        }
                        function onTxtKeyDown() {
                            if (to) clearTimeout(to);
                        }
                        function performSearch(buttonid) {

                            if (prm.get_isInAsyncPostBack) {
                                prm.abortPostBack();
                            }

                            //             $get("<%=lblStatus.ClientID %>").innerHTML = "Loading...";
                            __doPostBack(buttonid, "");
                            //           __doPostBack("<%=btnSearch.UniqueID %>", "");
                        }
                  </script>


and its working properly. the next I am using for a doubleclick is


XML
<script type="text/javascript">
    function clickButton(e, buttonid) {
        debugger;
        var evt = e ? e : window.event;
        var bt = document.getElementById(buttonid);
        if (bt) {
            bt.click();
        }
    }
      </script>



and it is not working
Posted

1 solution

I can see one issue with your usercontrol.

Since you have not externalized your user control's javascript, so if the user control is used mutiple times in a page then the javascript code will get repeated.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900