0

I don't understand what is wrong with my code. It is very basic, but still there is an error.

In the header tag I have the following script, you can skip your attention to the last function, which is the one I need for this question:

    <script type="text/javascript">

        function allowOnlyNumber(evt)
        {
            var charCode = (evt.which) ? evt.which : event.keyCode

            if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode != 46)
                return false;


          return true;
        }

        function checkboxalert() {
            var active = document.getElementById("chkActive").checked;
            var inactive = document.getElementById("chkInactive").checked;

            if ((!active) && (!inactive)) alert("Please ensure that either Active or Inactive is checked before limiting search, otherwise, Active records will be assumed...")
        }


        function lostfocusLowPrice() {
            if (getElementById("txtFindHighPrice").value = "" && getElementById("txtFindLowPrice").Value != "") getElementById("txtFindLowPrice").Value = getElementById("txtFindLowPrice").Value;
        }


    </script>

In the design of my web page, I have this:

<asp:TextBox ID="txtFindLowPrice" OnTextChanged="lostfocusLowPrice()" onkeypress="return allowOnlyNumber(event)" runat="server" Height="22px" Width="63px"></asp:TextBox>

I get a compilation error:

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1061: 'webform1_aspx' does not contain a definition for 'lostfocusLowPrice' and no extension method 'lostfocusLowPrice' accepting a first argument of type 'webform1_aspx' could be found (are you missing a using directive or an assembly reference?)

Spelling matches. Code is very basic. Can't imagine what it might be. Other javascript functions work fine.

Any ideas?

1
  • Amamath has a good answer below, but is there a client side solution for what I am trying to do? Commented Jun 12, 2019 at 17:03

1 Answer 1

1

OnTextChanged event is a server side event so here it is searching the lostfocusLowPrice method in .cs file and throwing the above error. for learn more about OnTextChanged event. Please refer below link. https://meeraacademy.com/textbox-autopostback-and-textchanged-event-asp-net/

below one also: ASP textbox calls javascript function

Sign up to request clarification or add additional context in comments.

1 Comment

good answer. so is there a client-side solution to do what I am trying to do?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.