Link to home
Create AccountLog in
Avatar of r3nder
r3nderFlag for United States of America

asked on

passing values and suuming them from a usercontrol

I have a user control(child) as a popup on a user control(parent)
In the child I have 3 textboxes. On the parent I have 3 textboxes.  I need to pass back to the parent usercontrol the value entered into the textboxes = then when  they add another one it adds to the values in the parent text boxes
for example
Childtextbox 1 = 3
Childtextbox 2 = 1
Childtextbox 3 = 2
parenttextbox 1 = 3
parenttextbox2 = 1
parenttextbox = 2
Add another-------
Childtextbox 1 = 2
Childtextbox 2 = 2
Childtextbox 3 = 1
parenttextbox 1 now reads  = 5
parenttextbox 2 now reads  = 3
parenttextbox = 3

How do I  do that
Avatar of harshada_sonawane
harshada_sonawane

u can achieve this using j query


   var grandTotal = 0;
            $("[id*=Childtextbox1]").each(function() {

                grandTotal = grandTotal + parseFloat($(this).val());
            });

 $("[id*=parenttextbox1]").html("$" + Number(grandTotal).toFixed(2).toString());
SOLUTION
Avatar of John Claes
John Claes
Flag of Belgium image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
ASKER CERTIFIED SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of r3nder

ASKER

I added my stubs to the parent form
        public string CriticalValue { get; set; }
        public string MajorValue { get; set; }
        public string MinorValue { get; set; }

Open in new window

I added to the parent show dialog
            if (form.ShowDialog() == DialogResult.OK)
            {
             radtxtCriticalTotal.Text = radtxtCriticalTotal.Text + CriticalValue; 
             radtxtMajorTotal.Text = radtxtMajorTotal.Text  + MajorValue;
             radtxtMinorTotal.Text = radtxtMinorTotal.Text + MinorValue;
            }

Open in new window


In the child i added my stubs
public string CriticalValue { get { return radtxtCritical.Text; } }
        public string MajorValue { get { return radtxtMajor.Text; } }
        public string MinorValue { get { return radtxtMinor.Text; } }

Open in new window


but its not working - any ideas?
Avatar of r3nder

ASKER

got it

if (form.ShowDialog() == DialogResult.OK)
            {
             radtxtCriticalTotal.Text = radtxtCriticalTotal.Text + war.CriticalValue;
             radtxtMajorTotal.Text = radtxtMajorTotal.Text  + war.MajorValue;
             radtxtMinorTotal.Text = radtxtMinorTotal.Text + war.MinorValue;
            }
Good for you ....I was working through to sent you another post....:)
Avatar of r3nder

ASKER

Thank  you both! Worked after I added
newCritical = Convert.ToInt32(radtxtCriticalTotal.Text) +Convert.ToInt332( war.CriticalValue)
radtxtCriticalTotal.Text = Convert.ToString(newCritical);