Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Intertrelated controls
Message
From
20/09/2010 15:58:06
 
 
To
20/09/2010 15:33:03
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 3.0
Miscellaneous
Thread ID:
01482058
Message ID:
01482074
Views:
41
Tim,

even if I use one method I still get the same symptoms. If I have the date as 20/09/2020 and the Age is 60, I can change the date to 20/09/2025 and the age will change to 65, but if I change the age back to 60, the date won't changed and the age gets changed to 65!

The tab order is the date control, then a button, then the age control. A post back is done and I haven't told the page which control to set focus to next yet, so nothing seems to have focus after changing either value.

>Frank,
>
>For starters, I would put all that code in one method. You can create a single TextChanged event handler and point both text boxes to the same one. You will know which one raised the event by creating a textbox from the source object. Something like this to get you started.
>
>What is the tab order between these two controls. If they change one and this event fires, does it move right to the other?
>
>
>protected void txtPolicyExpiry_TextChanged(object sender, EventArgs e)
>{
>     mmTextBox source = (TextBox)sender;
>     if (source.ID == "txtExpiryDate")
>     {
>          // Do one thing
>     }
>     else
>     {
>          // Do the other
>     }
>}
>
>Tim
>
>>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
Previous
Reply
Map
View

Click here to load this message in the networking platform