ClientEvents-OnValueChanged calculate sum Not working in Q2 2012

4 posts, 1 answers
  1. Hu
    Hu avatar
    2 posts
    Member since:
    Dec 2011

    Posted 03 Jul 2012 Link to this post

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="mtidb_app.test" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head id="Head1" runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <telerik:RadScriptManager ID="radsm" runat="server" EnablePageMethods="true" EnablePartialRendering="true" />  
        <telerik:RadWindowManager ID="RadWindowManager2" runat="server" EnableShadow="true" ></telerik:RadWindowManager>
        <telerik:RadAjaxManager ID="radam" runat="server" EnableHistory="True"></telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel id="LoadingPanel" Runat="server" Transparency="30" EnableSkinTransparency="false" Width="100%" Height="100%" BackgroundPosition="Center"  >   
        </telerik:RadAjaxLoadingPanel>  
        
        <telerik:RadAjaxPanel ID="radp4" runat="server" LoadingPanelID="LoadingPanel" Width="100%" >
        <telerik:RadCodeBlock ID="RadCodeBlock4" runat="server">
            <script type="text/javascript">
                function CalculateAdjustment() {
                    var reg = $find("<%= tbAdjustReg.ClientID %>");
                    var tuition = $find("<%= tbAdjustTuition.ClientID %>");
                    var admin = $find("<%= tbAdjustAdmin.ClientID %>");
                    var supply = $find("<%= tbAdjustSupply.ClientID %>");
                    var uniform = $find("<%= tbAdjustUniform.ClientID %>");
                    var textbook = $find("<%= tbAdjustTextbook.ClientID %>");
                    var other = $find("<%= tbAdjustOther.ClientID %>");
                    var tax = $find("<%= tbAdjustTax.ClientID %>");
                    var total = $find("<%= tbAdjustTotal.ClientID %>");

                  if (reg.get_value() == '') reg.set_value('0');
                   if (tuition.get_value() == '') tuition.set_value('0');
                    if (admin.get_value() == '') admin.set_value('0');
                    if (supply.get_value() == '') supply.set_value('0');
                    if (uniform.get_value() == '') uniform.set_value('0');
                    if (textbook.get_value() == '') textbook.set_value('0');
                    if (other.get_value() == '') other.set_value('0');
                    if (tax.get_value() == '') tax.set_value('0');

                    total.set_value(reg.get_value() + tuition.get_value() + admin.get_value() + supply.get_value() + uniform.get_value() + textbook.get_value() + other.get_value() + tax.get_value());
                }
            </script>
        </telerik:RadCodeBlock>                    

    <div><telerik:RadNumericTextBox ID="tbAdjustReg" runat="server" ClientEvents-OnValueChanged="CalculateAdjustment" Type="Currency" NumberFormat-DecimalDigits="2" Width="110" /></div>
    <div><telerik:RadNumericTextBox ID="tbAdjustTuition" ClientEvents-OnValueChanged="CalculateAdjustment" runat="server" Type="Currency" NumberFormat-DecimalDigits="2" Width="110" /></div>
    <div><telerik:RadNumericTextBox ID="tbAdjustAdmin" ClientEvents-OnValueChanged="CalculateAdjustment" runat="server" Type="Currency" NumberFormat-DecimalDigits="2" Width="110" /></div>
    <div><telerik:RadNumericTextBox ID="tbAdjustSupply" ClientEvents-OnValueChanged="CalculateAdjustment" runat="server" Type="Currency" NumberFormat-DecimalDigits="2" Width="110" /></div>
    <div><telerik:RadNumericTextBox ID="tbAdjustTextbook" ClientEvents-OnValueChanged="CalculateAdjustment" runat="server" Type="Currency" NumberFormat-DecimalDigits="2" Width="110" /></div>
    <div><telerik:RadNumericTextBox ID="tbAdjustUniform" ClientEvents-OnValueChanged="CalculateAdjustment" runat="server" Type="Currency" NumberFormat-DecimalDigits="2" Width="110" /></div>
    <div><telerik:RadNumericTextBox ID="tbAdjustOther" ClientEvents-OnValueChanged="CalculateAdjustment" runat="server" Type="Currency" NumberFormat-DecimalDigits="2" Width="110" /></div>
    <div><telerik:RadNumericTextBox ID="tbAdjustTax" ClientEvents-OnValueChanged="CalculateAdjustment" runat="server" Type="Currency" NumberFormat-DecimalDigits="2" Width="110" /></div>
    <div><telerik:RadNumericTextBox ID="tbAdjustTotal" ReadOnly="true" runat="server" Type="Currency" NumberFormat-DecimalDigits="2" Width="110" /></div>
    </telerik:RadAjaxPanel>
    </form>
    </body>
    </html>


    The code working well in v2.0.50727 version but when i try to switch Q2 2012, it is just stop working.
    Pls hlp
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 04 Jul 2012 Link to this post

    Hello,

    You can use _SetValue method instead of set_value method which fires the client event OnValueChanged event in Q2 2012. Here is the sample code.
       if (reg.get_value() == '') reg._SetValue('0');
    if (tuition.get_value() == '') tuition._SetValue('0');
    if (admin.get_value() == '') admin._SetValue('0');
    if (supply.get_value() == '') supply._SetValue('0');
    if (uniform.get_value() == '') uniform._SetValue('0');
    if (textbook.get_value() == '') textbook._SetValue('0');
    if (other.get_value() == '') other._SetValue('0');
    if (tax.get_value() == '') tax._SetValue('0');

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Hu
    Hu avatar
    2 posts
    Member since:
    Dec 2011

    Posted 04 Jul 2012 Link to this post

    Thanks for reply.
    Yes, it works, but have another problem here.
    I set all fields as Currency. and seems that _SetValue() just set the value, and "$" not showing.
    I tried _SetValue('$0.00'); but it still just showing as "0" without currency symbol.
  5. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 05 Jul 2012 Link to this post

    Hello,

    I also observed the same behavior in Q2 2012. I was able to resolve it by setting set_displayValue(). Here is the sample code.
    JS:
    if (supply.get_value() == '') { supply._SetValue('0'); supply.set_displayValue('$0.00'); }
     if (uniform.get_value() == '') { uniform._SetValue('0'); uniform.set_displayValue('$0.00'); }
    if (textbook.get_value() == '') { textbook._SetValue('0'); textbook.set_displayValue('$0.00'); }

    Thanks,
    Shinu.
Back to Top