Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6226589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:03:35+00:00 2026-05-24T09:03:35+00:00

I have a 3 textboxes on a page quantity, price and total . When

  • 0

I have a 3 textboxes on a page quantity, price and total . When the quantity and price are entered by the user the total is being calculated directly by using javascript.
Below is the code:

   function quantity(textvalue) {
    var qty = textvalue.value;
    var price = document.getElementById('<%=Price.ClientID %>').value;
    var Total = Math.round(qty * price * 100) / 100;

    document.getElementById('<%=Total.ClientID %>').value = Total;

}

   function Price(textvalue) {
    var price = textvalue.value;
    var qty = document.getElementById('<%=Quantity.ClientID %>').value;
    var Total = Math.round(qty * price * 100) / 100;

    document.getElementById('<%=Total.ClientID %>').value = Total;

}

 <asp:TextBox ID="Quantity" runat="server" onchange="javascript: quantity(this);" CausesValidation="True"></asp:TextBox>
      <asp:TextBox ID="Price" runat="server" onchange="javascript: Price(this);"  ></asp:TextBox>
        <asp:TextBox ID="txtLineItemTotal" runat="server" Width="120px" MaxLength="14" ReadOnly="true"  
        BackColor="Silver" BorderWidth="2px" style="font-weight: 700">0.00</asp:TextBox>

I also need to validate the value calculated in the total textbox and it should not exceed 100000000000.00.

I am using the below function to achieve this

function TotalChanged() {
    var lineitemtotal = document.getElementById('<%=Total.ClientID %>').value;
    alert("entered function");
    if (lineitemtotal >= 100000000000.00) {
        alert("Total cannot exceed 100000000000.00,please re-enter");
    }
    else
        return false;
    }

And on Page Load

 Total.Attributes.Add("onchange", "{return TotalChanged()};");

But it is not entering the function, please let me know what am I missing…or if I am using the wrong event…trying it for the past 1 day….:(

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:03:37+00:00Added an answer on May 24, 2026 at 9:03 am

    For starters, if you’re using ASP.NET 4.0, you’ll want to use ScriptManager or ClientScriptManager’s .RegisterExpandoAttribute method as demonstrated below using ClientScriptManager:

    Page.ClientScript.RegisterExpandoAttribute(controlId, attributeName, attributeValue, false);
    

    The final boolean argument is for the “encode” parameter. You must set this to false. As a surprise new feature in ASP.NET 4, all of your attribute values are HTML Encoded. Great for security, but really bad for event handlers / scripts emitted from the server side.

    UPDATE:

    In your specific case, the RegisterExpandoAttribute would be implemented as:

    Page.ClientScript.RegisterExpandoAttribute(Total.UniqueID, "onchange", "return TotalChanged();", false);
    

    Note the absence of the curly brackets encapsulating my handler. Those curly brackets might be causing your problem if you’re not on ASP.NET 4 but your method still isn’t being called. You’re effectively wrapping your event handler in an object literal.

    Good luck. If this doesn’t fix your problem provide some more info and I’ll try to offer other ideas.

    B

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have taken three textboxes over aspx page. A JavaScript function is associated with
So I have this empty textboxes in a registrationg page. The user enters some
I have textboxes loaded with data on my ASP.NET MVC page. If the user
I have a page which uses javascript to add some textboxes to the page,
I have few textboxes on one page and one user control. What I want
My data is being correctly loaded on my page. However I have 2 textboxes
I have some textboxes on a page and I want to click a link
I have multiple input textboxes in my page. I want to reset particular text
I have a login page that has several textboxes on the page, one of
I have a ASP.NET web page that contains many textboxes. Each textbox has a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.