We help IT Professionals succeed at work.
Get Started

jQuery webforms value created by jQuery does

Charles Baldo
on
85 Views
Last Modified: 2016-02-25
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
Comment
Watch Question
Software Architect
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE