Avatar of Charles Baldo
Charles Baldo
Flag for United States of America

asked on 

jQuery webforms value created by jQuery does

I have these webform controls

<asp:TextBox ID="HoursWorkedMonday" CssClass="data-input rt" ClientIDMode="Static" runat="server" TabIndex="2" />
....
....
....
<asp:TextBox ID="HoursWorkedSaturday" CssClass="data-input rt" ClientIDMode="Static" runat="server" TabIndex="2" />
...
...
 <asp:TextBox ID="TotalRegular" CssClass="data-input" ClientIDMode="Static" runat="server" Enabled="False" /></div>

The hours are for TotalRegular are accumulated with jquery

       

            $(".rt").each(function () {

                $(this).focusout(function () {
                   [b] calculateRegularHoursSum();[/b]
                });
            });

  function [b]calculateRegularHoursSum()[/b] {
            var sum = 0;
            $(".rt").each(function () {

                if (!isNaN(this.value) && this.value.length != 0) {
                    sum += parseFloat(this.value);
                }
            });
            $("#TotalRegular").val(sum)
        }

Open in new window


If I populate the controls from code behind in c#  when I run this code in jQuery



                    var reghours = $("#TotalRegular").val();
                        if (!reghours.trim()) reghours = 0;
                        $("[id$='regularhours']").html(reghours).text();



        <div id="ConfirmPanel" style="display:none">
            <div class="dialog-label">Regular Hours</div>
            <asp:Label ID="regularhours" CssClass="hours-label" runat="server" /><br />
            <div class="dialog-label">Overtime Hours</div>
            <asp:Label ID="overtimehours" CssClass="hours-label" runat="server" /><br /><br />
        </div>

Open in new window



the dialog displays nothing.  Only if I go in one of those fields and do a focusout() does the control have values
jQueryASP.NET

Avatar of undefined
Last Comment
Charles Baldo

8/22/2022 - Mon