Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Intertrelated controls
Message
From
20/09/2010 14:46:36
 
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
Intertrelated controls
Environment versions
Environment:
C# 3.0
Miscellaneous
Thread ID:
01482058
Message ID:
01482058
Views:
110
Hi,

I have two controls on an ASP.NET page. One is a Date of maturity and the other is the Age at maturity. The requirement is that when the Date of Maturity changes, the Age at Maturity should reflect the new date and vice versa (if the age is changed then the date should reflect the new age).

I have it working so that my date is defined like this:
<mm:mmTextBox ID="txtExpiryDate" runat="server" BindingSource="Policy" BindingSourceMember="ExpiryDate"
DisplayFormat="{0:d}" Width="79px" CssClass="date" AutoPostBack="true" OnTextChanged="txtExpiryDate_TextChanged"></mm:mmTextBox>

<mm:mmTextBox ID="txtRetirementAge" runat="server" BindingSource="Policy" BindingSourceMember="RetirementAge"
Width="54px" AutoPostBack="true" OnTextChanged="txtRetirementAge_TextChanged"></mm:mmTextBox>
My code is this:
        protected void txtExpiryDate_TextChanged(object sender, EventArgs e)
        {
            // update Age at retirement
            if (this.oPlan.Entity.PlanTypeFK == 1)  // Annuity
            {
                // work out age at retirement
                this.txtRetirementAge.Text = this.oClient.GetAgeNearest(this.oClient.Entity.DateOfBirth, Convert.ToDateTime(this.txtExpiryDate.Text)).ToString();
            }

        }

        protected void txtRetirementAge_TextChanged(object sender, EventArgs e)
        {
            // update Date of expiry/maturity
            if (this.oPlan.Entity.PlanTypeFK == 1)  // Annuity
            {
                // work out the age difference between age at issue and retirement age
                Int16 ageDiff = (Int16)(Convert.ToInt16(this.txtRetirementAge.Text) - oPolicy.Entity.AgeAtIssue);

                // add the difference to the issue date
                DateTime dt = (DateTime)this.oPolicy.Entity.IssueDate;
                dt = dt.AddYears(ageDiff);
                this.txtExpiryDate.Text = dt.ToString();
            }
        }
This works fine if I change the date, the age gets recalculated properly. But if I change the age, and I set a breakpoint in xtRetirementAge_TextChanged, it is showing me that the this.txtRetirementAge.Text is the old value, not the value I just entered!

I'm wondering if it has to do with the age changing, which changes the date which changes the age (and so on).

How would you suggest I approach this?
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Next
Reply
Map
View

Click here to load this message in the networking platform