troubleshooting Question

jQuery webforms value created by jQuery does

Avatar of Charles Baldo
Charles BaldoFlag for United States of America asked on
jQueryASP.NET
2 Comments1 Solution88 ViewsLast Modified:
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)
        }

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>


the dialog displays nothing.  Only if I go in one of those fields and do a focusout() does the control have values
ASKER CERTIFIED SOLUTION
Alexandre Simões
Software Architect

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros