View Single Post
  #1 (permalink)  
Old August 3rd, 2011, 05:21 AM
ddkdiiro ddkdiiro is offline
Registered User
 
Join Date: Aug 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default onchenge in the textbox(Post back)

Dear members,
I have encountered this problem for sometime but i have failed to get the solution. I have written my code below in C#.net wanting the Webform to automatically calculate the values from the textboxes as they are entered and displays them at the sametime in the result text box. As the user enters. Please go throu this problem below

================================================== =====
private void Qty_Init(object sender, System.EventArgs e)
{
this.Qty.AutoPostBack = true;
this.Qty.TextChanged += new System.EventHandler(Qty_TextChanged);
}
================================================== ========



private void Qty_TextChanged(object sender, System.EventArgs e)
{
Regex regex = new Regex("^[0-9]*&");
if(regex.IsMatch(this.Qty.Text) && !string.IsNullOrEmpty(this.Qty.Text.Trim()))
{
double Balance1;
double Amount1 = Convert.ToDouble(this.Qty.Text);
double Amount2 = Convert.ToDouble(this.Unit_Cost.Text);

Balance1 = Amount1 * Amount2;
this.AmountPaid.Text = Convert.ToString(Balance1);
//Balance1 = Convert.ToDouble(this.Balance.Text);

}
}